<b>Linux Journal:</b> "After a recent O/S version upgrade (to openSUSE 11.2) I noticed that bash started being a bit more intelligent when I did something stupid: it started giving me a useful error message..."
Hi.
I'm trying to call a shell script every 5 minutes, witch executes php file under root.
# crontab -l
*/5 * * * * /home/regularuser/call.sh
permissions:
-rw-rw-rw- 1 root root 162 Jun 6 23:40 call.php
-rwxr-xr-x 1 root root 66 Jun 7 01:20 call.sh
call.sh contents:
#!/bin/bash
php -q /home/regularuser/call.php
echo "request processed"
My problem is that my php file doesn't get executed via crontab. However, if I call call.sh - everything works perfectly.
I'm new to crontab and shell scripting, so any advice/resources are welcome.
tl;dr: How does the ubuntu user on the AWS images for Ubuntu Server 12.04 have passwordless sudo for all commands when there is no configuration for it in `/etc/sudoers'?
I'm using Ubuntu server 12.04 on Amazon. I want to add a new user that has the same behaviour as the default ubuntu user. Specifically I want passwordless sudo for this new user.
So I've added a new user and went to edit /etc/sudoers (using visudo of course). From reading that file it seemed like the default ubuntu user was getting it's passwordless sudo from being a member of the admin group. So I added my new user to that. Which didn't work. Then I tried adding the NOPASSWD directive to sudoers. Which also didn't work.
Anyway, now I'm just curious. How does the ubuntu user get passwordless privileges if they aren't defined in /etc/sudoers. What is the mechanism that allows this?
I'm making a simple bullet hell game but I can't figure out how to get my character to shoot. Lets say I have bulletBody and shipBody, how would I continually spawn bulletBodies using the shipBody coordinates. I've tried a function that uses an array of b2bodies and just assigns them the bodydef and fixture but that causes the game to crash. C++ sample code would be best but any help is appreciated.
EDIT: It looks like any reference to my b2World in a function will cause the game to crash. How do I declare the bodies without using a b2World as an argument in the function.
On my Linux box (Gentoo Linux 2.6.31 to be specific) I have noticed that the HOSTNAME environment variable is available in my shell, but not in scripts. For example,
$ echo $HOSTNAME
returns
xxxxxxxx.com,
but
$ ruby -e 'puts ENV["HOSTNAME"]'
returns
nil
On the other hand, the USER environment variable, for instance, is available both in the shell and in scripts.
I have noticed that USER appears in the list of environment variables that appears when I type
export
i.e.,
declare -x USER="infogrind"
but HOSTNAME doesn't. I suspect the issue has something to do with that.
My questions: 1) how can I make HOSTNAME available in scripts, and 2) for my better understanding, where is this variable initially set, and why is it not "exported"?
Is it possible to create a terminal application which uses cocos2d? I've tried to make one using cocos2d 2.x, but it requires a MacGLView to be initialized.
I need it so that I could program a terminal application that generates a screenshot given a TMX file and an optional preferred width or height parameter (for resizing). Then I can automate the generation of map previews for my game, instead of manually taking screenshots. It's not practical to load the actual TMX and resize it inside the game (what I'm currently doing), because each TMX file has 7 layers, my tile sheet is huge, and I have lots of levels.
<b>The Geek Stuff:</b> "In this article, let us review various tar examples including how to create tar archives (with gzip and bzip compression), extract a single file or directory, view tar archive contents, validate the integrity of tar archives, finding out the difference between tar archive and file system, estimate the size of the tar archives before creating it"
I have kind of an odd problem. The time in my Unity bar is right, but the time in bash is 2 hours ahead.
$ date
Wed Jun 20 15:31:55 CDT 2012
Unity bar:
Wed Jun 20 13:31:55
Here are my etc configs:
$ cat /etc/timezone
America/Los_Angeles
locale:
$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Finally, I tried $ sudo dpkg-reconfigure tzdata and setting it to "Los_Angeles".
Has anyone seen anything like this?
I'm running 10.04LTS inside VMWare Fusion on a Mac.
The [command] key (aka [windows] on many keyboards) is almost always behaving as if it was [ctrl], even though I done anything explicit to request that behavior.
In fact, in SystemPreferencesKeyboardLayoutsOptionsAlt/Win key behavior, 'default' is chosen (rather than the 'Control is mapped to Win keys' option). However, choosing other options there do not seem to change the handling of [command], at least not as tested in the SystemPreferenceKeyboard Shortcuts app. (No matter what I've tried, [command]-x is always detected as [Ctrl]-x in that app.)
I've tried:
various options under SystemPreferencesKeyboardLayoutsOptionsAlt/Win key behavior
toggling the VMWare Fusion Preferences KKeyboard & Mouse Key Mappings setup which claims to map '[command]' to '[windows]', and restarting the VM in each position
the xmodmap lines suggested at https://help.ubuntu.com/community/MappingWindowsKey
And yet, it's clear that all Ubuntu apps aren't merging [ctrl] and [command], because in 'Terminal', [shift]-[ctrl]-c will Copy, but [shift]-[command]-c will not.
If the [command]/[windows] key was recognized as anything else ('Super', 'Meta', 'Hyper'? I don't care as long as it's not 'Control'), then I could achieve my real goal (which happens to be enabling CMD-based cut/copy/paste in PyCharm, while leaving CTRL-X/etc available for emacs-like bindings). I think any solution which manages to make [command]-x appear as something other than [ctrl]-x in PreferencesKeyboard Shortcuts will probably do the trick.
I have XAMPP installed and my PHP is:
/opt/lampp/bin/php-5.3.8
Every time I need to execute a PHP file I need to do this:
/opt/lampp/bin/php-5.3.8 testando.php
Is there another way to execute it besides using symbolic link?
I did this on /etc/init.d/:
sudo ln -s /opt/lampp/bin/php-5.3.8 php
Why when I need to run PHP I have to do this ./php instead of just php?
And is there a way to do this without the ./? Like it was installed via apt-get?
Hi,
I have 5 machines I constantly ssh into to do work. Its getting increasingly frustrating when I am issuing wrong commands on wrong boxes. Luckily I havent done anything bad yet. I wanted to know if there is any hack which I can hardcode which will display my prompt in different colors based on the machine I am ssh into? Such as blue for desktop1, purple for laptop, red for server etc? Is this possible?
Currently I am using this command export PS1="\e[0;31m[\u@\h \W]\$ \e[m " taken from here http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/ but it obviously doesnt work across ssh.
Also, if you have any other cool bash tips for helping me ease my sight will be wonderful. I got this tip which colors the man pages.
http://linuxtidbits.wordpress.com/2009/03/23/less-colors-for-man-pages/
Hi!
I have this FeedIndexer.sh:
#!/bin/sh java -jar FeedIndexer.jar
Just to run FeedIndexer.jar which is in the same directory as the .sh, I would like to run it using crontab, so I did this:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
01 01 * * * root run-parts --report /home/slosada/workspace/FeedIndexer/target/FeedIndexer.sh
#
But I don't know how to run it. Have i made any mistake??
Thank you!
I am getting an error while executing a remote PowerShell script. From my local machine I am running a PowerShell script that uses Invoke-Command to cd into a directory on a remote Amazon Windows Server instance, and a subsequent Invoke-Command to execute script that lives on that server instance. The script on the server is trying to git clone a repository from GitHub. I can successfully do things in the server script like "ls" or even "git --version". However git clone, git pull, etc. result in the following error:
Cloning into 'MyRepo'... + CategoryInfo : NotSpecified: (Cloning into 'MyRepo'...:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
This is my first time using PowerShell or a Windows Server. Can anyone provide some direction on this problem.
The client script:
$s = new-pssession -computername $server -credential $user
invoke-command -session $s -scriptblock { cd C:\Repos; ls }
invoke-command -session $s -scriptblock { param ($repo, $branch) & '.\clone.ps1' -repository $repo -branch $branch} -ArgumentList $repository, $branch
exit-pssession
The server script:
param([string]$repository = "repository", [string]$branch = "branch")
git --version
start-process -FilePath git -ArgumentList ("clone", "-b $branch https://github.com/MyGithub/$repository.git") -Wait
I've changed the server script to use start process and it is no longer throwing the exception. It creates the new repository directory and the .git directory but doesn't write any of the files from the github repository. This smells like a permissions issue. Once again invoking the script manually (remote desktop into the amazon box and execute it from powershell) works like a charm.
Using bash, how can one get the number of files in a folder, excluding directories from a shell script without the interpreter complaining?
With the help of a friend, I've tried
$files=$(find ../ -maxdepth 1 -type f | sort -n)
$num=$("ls -l" | "grep ^-" | "wc -l")
which returns from the command line:
../1-prefix_blended_fused.jpg: No such file or directory
ls -l : command not found
grep ^-: command not found
wc -l: command not found
respectively. These commands work on the command line, but NOT with a bash script.
Given a file filled with image files formatted like 1-pano.jpg, I want to grab all the images in the directory to get the largest numbered file to tack onto the next image being processed.
Why the discrepancy?
I had an idea of using my Windows VM (on a Ubuntu host) to open itms:// links (for iTunes) from the host. So, I'm using vboxmanage guestcontrol to make this happen.
I have a script (win_vm_launcher.sh) that takes a link as the argument, and passes it to the host like this:
vboxmanage guestcontrol "$VM" exec --image 'C:\Windows\System32\cmd.exe' --username "$USER" --password "$PASSWORD" -- /c start "$@"
This works if I copy a link from my browser, and change http to itms. E.g., for https://itunes.apple.com/us/album/new-york-city/id3202598, I can do win_vm_launcher.sh itmss://itunes.apple.com/us/album/new-york-city/id3202598 and it works fine. The album opens up in iTunes on my VM.
However, when I click a "View in iTunes" link from the iTunes site, it adds an extra parameter to the URI (specifically, the referrer), so it looks something like itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739
Unfortunately, if I try to run win_vm_launcher.sh itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739 it insteads opens up a regular Command Prompt window with the title "itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739". I don't even know how to set the command prompt window title, so I'm not sure how that's happening.
If I run the command in the guest, it works fine, opening the album in iTunes:
cmd /c start itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739
I found a VirtualBox bug that seems somewhat related, but not exactly.
It probably doesn't matter, but my host is Ubuntu 12.04, and my guest is Windows 7.
So, any idea if vboxmanage is incorrectly passing the arguments, and if so, is there a way around it?
If I can't figure out the right way to do it, I'll end up having to process each argument, and stripping out any parameters on any URIs.
P.S.
I tried creating a batch script (out.bat) like this:
echo %1 > %TEMP%/testing.txt
and then running it from the host like this: vboxmanage guestcontrol "$VM" exec --image 'C:\Windows\System32\cmd.exe' --username "$USER" --password "$PASSWORD" -- /c "C:\path\to\out.bat" "itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739"
It ran as expected, and when I open %TEMP%/testing.txt, it contained:
"itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739"
including the quotes. So, it sort of passed the parameter correctly (not sure why it still had quotes), so maybe the problem is with cmd.exe, or even the start command. I'm stymied.
I have some command-line commands to execute on a Windows machine. The programs I need to run are only available on Windows.
Is there a way to easily to do something like I would do with SSH? Example of what I mean:
ssh [email protected] "remote command to execute"
...or do I have to Remote Desktop just to do this? (I'd like to run the commands programmatically from another computer rather than running them by hand.)
How can I specify multiple startup tasks in Conemu? I want to have each task in a separate tab opened on startup.
Something like:
ConEmu64.exe /cmdlist {Powershell}|{FAR}|{VSConsole}
Unfortunately, this command does not support "console scripts" ("Console script are not supported here").
I know, I can create another task, combining the commands of my desired tasks (full commands, because task command does not support console scripts). Is there any other way ?
Please share your favorite mc tips here.
My favorites:
I just learned that Alt+. enables easily to toggle display of hidden files (on mc 4.7).
Ctrl+\ - favorite dirs
Alt+s - quick search
BTW:
how to use command line completion without switching to Ctrl+o mode? (TAB does not work, since it changes panels)
how to insert full path of the current panel into the command line?
I'm trying to show the number of lines, words and characters of all configuration files in /etc/*conf (with command wc).
How can I modify the command (or commandline) to not view the error messages?
I would like to extract a "book cover image" from a series of CHM files, which command line tool can do that, please?
I have looked at the source of the QuickLook plug-in "quickchm1.1_source" and at the calibre command line conversion options (ebook-convert) but couldn't find anything akin to simple:
name_of_tool file_to_convert output_image
as in:
mytool routermanual.chm routermanualcoverimage.png
From a Windows XP command line, how do I get the time I logged into and/or out of the current machine? I'm looking for something like the UNIX last command which lists active and previous login sessions.
Thanks,
John
I know that the copy command has an option to automatically replace a file if it already exists, but I want to know if it is a way to copy the files only if they not already exist (/Y). I do not know the actual file names in the batch code, as I copy from the source using wildcards in the copy command:
copy *.zip c:\destination
The reason I want this instead of automatic overwrite is that the files are large, and to skip existing would save a lot of execution time.
I am attempting to use the zip -r command to zip a folder which includes two files. I need to pass the absolute path of the folder with two files (/path/to/my/files/), which is causing all of the folders to be zipped with it, where as I only need the last folder (files/) and its contents to be zipped, so that when the file is unzipped, there is only one folder and the two files within it. How can I modify the command to be able to pass the absolute paths in the arguments while keeping only the last folder?
Hi, when I execute
./script &>> log.txt
I get a nice logfile, but if I have the same command executed by cron, lets say the crontab looks like this:
* * * * * '/home/user/script &>> /home/user/log.txt'
the log.txt will just be empty, I tried " and ' and ` and no ticks to enclose the command, any idea why the streams won't get written into the file?