[ale] Shell: dir name
Zyman, Andy
zymana at hra.nyc.gov
Tue May 21 10:43:29 EDT 2002
Chris,
WAV! That's perfect solution!
Thank You so much.
> -----Original Message-----
> From: Chris Coleman [mailto:chriscoleman at mail.clayton.edu]
> Sent: Tuesday, May 21, 2002 10:18 AM
> To: Joseph A Knapka; Zyman, Andy
> Cc: ale at ale.org
> Subject: RE: [ale] Shell: dir name
>
>
> dirname can be used to strip off the file name and leave the
> directory name. In a BASH shell, $0 is used to represent the
> path and name of the file being executed. Therefore I can use:
>
> dir_name=$(dirname $0)
>
> in side of the script to find out what directory the script
> was executed from.
>
> Chris Coleman
> -----Original Message-----
> From: Joseph A Knapka [mailto:jknapka at earthlink.net]
> Sent: Tuesday, May 21, 2002 9:50 AM
> To: Zyman, Andy
> Cc: 'ale at ale.org'
> Subject: Re: [ale] Shell: dir name
>
>
> "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.
>
---
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