[ale] Shell: dir name
Joseph A Knapka
jknapka at earthlink.net
Tue May 21 09:49:35 EDT 2002
"Zyman, Andy" wrote:
>
> Hello,
> i have simple question. but i somehow stuck on it.
>
> I need to find out from which dir. the scripts was executed.
> here is an example:
> cat /tmp/staff/script.sh
> #!/bin/ksh
> SPOOL_FILE=$PWD/log/spool_file.log
> echo $SPOOL_FILE
> #END
>
> After "manual" executing , the output is:
> /tmp/staff/log/spool_file.log
>
> this was working perfectly well until i cronned it.
>
> now in the output i basically have :
> $HOME/log/spool_file.log
>
> I thought there is an env. var which will point to the dir. The only one
> thing i found is $_. But it returns ( in case of ksh ) the whole
> path/script_name. And i just need dir. Any help?
I don't think there is such a variable (though I may be wrong).
But in your cron job, you could explicitly change to the
directory you want to exec the script from:
0 0 * * * ( cd /tmp/staff ; . ./script.sh )
-- Joe
Looking for a .sig...
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list