Click to See Complete Forum and Search --> : csh, getting the full path to script itself


villemos
May 16th, 2003, 02:12 AM
In a csh script (and yes I know csh can be bad for your health) I would like to know the position of the script itself, i.e. the full path to the script.

'pwd' doesn't work as the script can be called from somewhere different from its location. Passing the command line won't work either, as the script can be run locally (i.e. commandline './[script]'). And I don't wanna pass the path as a parameter.

So how can I get the full path to the script?

Thanks,
Villemos.

Satishpp
May 16th, 2003, 02:47 PM
I dont have a unix box to try this out...

Since you have the script name as the $0, you can run a 'which' command to get the path of the script.

Satish

villemos
May 16th, 2003, 05:05 PM
Thanks for the reply.

Somehow that feels like cheating ;). I was hoping for a system command or similar...?

Satishpp
May 16th, 2003, 05:13 PM
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_20606165.html

Satish