| Author |
Message |
TB *nix forums Guru Wannabe
Joined: 14 Mar 2005
Posts: 241
|
Posted: Mon Feb 07, 2005 12:04 pm Post subject:
Re: shell scripts and cron
|
|
|
I was assuming that nothing was happening because there was nothing in
the process table (ps -ef) after I ran it. |
|
| Back to top |
|
 |
Laurenz Albe *nix forums Guru
Joined: 21 Feb 2005
Posts: 478
|
Posted: Mon Feb 07, 2005 10:21 am Post subject:
Re: shell scripts and cron
|
|
|
Laurenz Albe <albe@culturallnospam.com> wrote:
<snip answer>
I replied before I found out that the guy multiposted in at least three
newsgroups :^P
Laurenz Albe |
|
| Back to top |
|
 |
Laurenz Albe *nix forums Guru
Joined: 21 Feb 2005
Posts: 478
|
Posted: Mon Feb 07, 2005 10:00 am Post subject:
Re: shell scripts and cron
|
|
|
TB <chessgame@gmail.com> wrote:
| Quote: | 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?
| Quote: | 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?
| Quote: | 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!
| Quote: | 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 |
|
| Back to top |
|
 |
TB *nix forums Guru Wannabe
Joined: 14 Mar 2005
Posts: 241
|
Posted: Mon Feb 07, 2005 3:32 am Post subject:
Re: shell scripts and cron
|
|
|
|
Forgot, this is AIX5.2 if that matters. |
|
| Back to top |
|
 |
TB *nix forums Guru Wannabe
Joined: 14 Mar 2005
Posts: 241
|
Posted: Mon Feb 07, 2005 3:25 am Post subject:
shell scripts and cron
|
|
|
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??? |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|