r_W213
February 27, 2007, 6:49am
1
hi,
I run a .sh file using crontab. I need to know the path of the file . Previously when I run the file alone , i used "pwd" but now when using crontab it gives the temp directory of the file.
Is there any way I can find the absolute path of the file when i execute it ?
Regards,
Ranga
"which <file>" would give you the absolute path. Is that what you need ?
reborg
February 27, 2007, 4:31pm
3
current_dir=`cd \`/usr/bin/basename $0\` && pwd`
r_W213
February 28, 2007, 12:40am
4
Hi
i tried the command
current_dir=`cd \`/usr/bin/basename $0\` && pwd`
I am getting the following. Can you please help me.
It is throwing a err: �/ss.sh: cd: ss.sh: Not a directory�
Regards,
Ranga
r_W213
February 28, 2007, 12:44am
5
hi,
Which <file> is giving me �./<file>� as o/p
Regards,
Ranga
reborg
February 28, 2007, 6:00am
6
Sorry, I must ahave been asleep when I posted that...
current_dir=`cd \`/usr/bin/dirname $0\` && pwd`
r_W213
February 28, 2007, 6:32am
7
hi,
Thanks for your prompt response. Will this work in csh and bash shells ?
I am executing the script in csh.
Regards,
Ranga
r_W213
March 1, 2007, 6:25am
8
Will this command `cd \`/usr/bin/dirname $0\` && pwd` change the directory or jus find the directory!!!
Regards,
Ranga