On Wed, Sep 21, 2016 at 09:43:15AM -0400, Tony Baldwin wrote:
Greetings, friends,I have various scripts in $HOME/bin, many of which I have put in my .config/openbox/rc.xml so I can fire them off with a keybinding combo, like<keybind key="W-b"> <action name="Execute"> <startupnotify> <enabled>true</enabled> <name>bid</name> </startupnotify> <command>bid</command> </action> </keybind> (This particular one does cat ~/Documents/bid | xclip -selection c) bid.txt being a template letter for bidding on translation projects. I use this to quickly copy the file and then paste it into an e-mail, then do any relevant edits.I'my lazy and like to automate things as much as possible where I can slap a few keys (Alt-m brings up icedove, Ctrl N to compose a new message, then W-b/Ctrl-v to copy and paste my bid template), These things used to work perfectly in Wheezy, and even in a previous Jessie installation, but working in a new Jessie installation,when I press W-b, and some others I get this: Failed to execute child process (no such file or directory) But the script IS in ~/bin/ $ which bid /home/tony/bin/bid and that dir IS in my $PATH: $ echo $PATH /home/tony/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games and it IS executable: $ ls -la bin/ | grep bid -rwxr-xr-x 1 tony tony 142 Oct 4 2012 bidI can execute these scripts from a terminal without any problem but not via the shortcuts in my rc.xml, nor with grun (shortcut W-r brings that up fine), nor with dmenu (W-p also working fine), and other stuffShortuts for stuff in /bin/ or /usr/bin/ (such as for icedove and iceweasel) seem to work fine, I can lock my screen (W-x engages slock); it's just my own scripts and stuff in ~/bin that are giving me trouble..Why?
Does the file start with a valid "shebang" line? When you tell some program to run a file "foo", typically what happens is that the program invokes a standard call (Actually, I'm not sure if this behaviour is in the kernel or in libc, either way, it's a "system function") that says "execute this file". Now, if the file is actually executable (e.g. something that you compiled), then you should be good to go, but if it's a script file, then... well the processor doesn't know how to interpret "echo Hello world".
However, if the first two characters of the file are "#!" (Pound/octothorpe/hash followed by exclamation-mark/bang... Hash-Bang... haSH-BANG... shebang), then the system identifies this file as a script. The remainder of that line (i.e. everything between the bang and the newline) is taken to be the actual command line to be run. So, that command is run instead and your script is passed to it on stdin.
So in summary, a script should start with something like: #!/bin/sh echo hello worldIt should follow, though, that you don't HAVE to add the shebang line IF you call a proper executable and pass it the name of your script. That is:
$ ~/bin/bid # Needs a shebang $ /bin/sh ~/bin/bid # Doesn't need a shebang, but it won't hurt Also, a few final things to be aware of: * Not all programs expand ~* ~ will expand to the home directory of the calling user (so watch out in cron jobs)
* Not all programs bother to search the PATHSo, if you're asking a program other than a full shell to execute something for you, it's best to give an absolute path.
tia, tony -- http://tonybaldwin.me all tony, all the time
-- For more information, please reread.
Description: PGP signature