vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I need a shell question answered if someone could. What happens if you don't put the traditional #!/bin/sh (or #!/bin/ksh) in the first line of a script?? Here is my problem. I have some very simple scripts that don't have this in the first line. A user's crontab is what normaly runs these scripts and they run fine. I needed to run one manually so I ran it as the full path. i.e. '/path/to/script/scriptname'. When I did, the cursor dropped to the next line and nothing else happened. I did a ps (from another session) and looked for the script in the process table. It was not there. But when I entered '/bin/sh /path/to/script/scriptname' the same thing happened with the prompt, but there was a process running in the ps table. These scripts have previously been ran manually but from the directory where they reside and it worked. How can they run from the directory, but not from the users home directory??? |
| |||
| TB <chessgame@gmail.com> wrote: > What happens if you don't put the traditional #!/bin/sh (or #!/bin/ksh) > in the first line of a script?? I guess the current shell is used. Try it out! Maybe the behaviour depends on the current shell... What is your current shell? What shells are installed on your system? What is your default shell? > Here is my problem. I have some very simple scripts that don't have > this in the first line. A user's crontab is what normaly runs these > scripts and they run fine. I needed to run one manually so I ran it as > the full path. i.e. '/path/to/script/scriptname'. When I did, the > cursor dropped to the next line and nothing else happened. Why do you assume that nothing happened? Just because you didn't see a thing? Or because you could not see it in the process list a long (by machine standards) time after you typed the command? > I did a ps > (from another session) and looked for the script in the process table. > It was not there. But when I entered '/bin/sh > /path/to/script/scriptname' the same thing happened with the prompt, > but there was a process running in the ps table. One way to see what is actually happening is to insert a 'set -x' near the beginning of the shell script. That way you get a trace of all commands executed on standard error. Look out for differences! > These scripts have previously been ran manually but from the directory > where they reside and it worked. How can they run from the directory, > but not from the users home directory??? For example, if they reference a relative file name. All your questions seem to lead in different directions, as if you haven't made up your mind yet what your problem is. Is there something special you want to achieve? Or (which is fine) are you just probing around and try to get a better understanding of how shell scripts work? Yours, Laurenz Albe |