![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2005
Posts: 10
Rep Power: 0
![]() |
Get Current Directory Of Script
can someone tell me a way to get the directory that the script is in from within the program?
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
[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.
__________________
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: May 2005
Posts: 10
Rep Power: 0
![]() |
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
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5
![]() |
look into CWD .... http://search.cpan.org/~kwilliams/Cwd-2.21/Cwd.pm
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ]; /* Don't make me use it! */ |
|
|
|
|
|
#5 |
|
Newbie
Join Date: May 2005
Posts: 10
Rep Power: 0
![]() |
I have seen CWD but it doesnt return the directory the script is in just the current working directory which isnt the same thing
|
|
|
|
|
|
#6 |
|
Professional Programmer
|
Isn't the program path and name in $0 or $$ or $_ or one of those special variables?
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;} |
|
|
|
|
|
#7 | |
|
Programmer
Join Date: Aug 2005
Location: 0x0010 * 0x0091 + 0x0004
Posts: 65
Rep Power: 3
![]() |
Quote:
__________________
#if 0 /* in case someone actually tries to compile this */ <Jim_McNeat> Is there like a way to put a compiler in "Just trust me on that one" mode? |
|
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
There may be something in a Win32 specific module that finds the path.
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Investigate GetFullPathName. Don't know that it's precisely what you're looking for.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#10 |
|
Hobbyist Programmer
Join Date: Oct 2005
Posts: 134
Rep Power: 3
![]() |
$ENV{'SCRIPT_NAME'} contains the name of the current running script as well as the full path. You could extract the path from that.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|