![]() |
Get Current Directory Of Script
can someone tell me a way to get the directory that the script is in from within the program?
|
[php]
#!/usr/bin/perl $pwd = ""; open(getPwd, "/bin/pwd |"); while(<getPwd>) { $pwd .= $_; } close getPwd; print "The working directory is, " . $pwd; [/php] There is probably a much simpler way, my perl skills are rudimentary. |
Im using windows and I cant follow what your script is supposed to do. It didn't work for me, can you explain your thought process
|
look into CWD .... http://search.cpan.org/~kwilliams/Cwd-2.21/Cwd.pm
|
I have seen CWD but it doesnt return the directory the script is in just the current working directory which isnt the same thing
|
Isn't the program path and name in $0 or $$ or $_ or one of those special variables?
|
Quote:
|
There may be something in a Win32 specific module that finds the path.
|
Investigate GetFullPathName. Don't know that it's precisely what you're looking for.
|
$ENV{'SCRIPT_NAME'} contains the name of the current running script as well as the full path. You could extract the path from that.
|
| All times are GMT -5. The time now is 8:39 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC