Unix Shell - Re: full path of a script

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2007 > Re: full path of a script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: full path of a script
Miles

2007-09-24, 1:26 pm

> You'd need to check
> whether $0 starts with /, if so, everything is fine and you're done
> else if it starts with ., prepend $(PWD) and (optionally) find a way to
> normalize that (e.g.: cd $(dirname $(pwd)/$0;pwd)

I agree 100%.

> else search $PATH until you find $0

No. There is no guarantee that the script is in your path.


Although, I am curious, why does the script need to know its own full
path?

Miles

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com