this is one of the standard annoyances... the concept of a CDW, PWD, OLDPWD
or whatever is a shell environment variable...
1) so you create a new shell (perl.exe) and cs somewhere and store the
directory in a file... (or whatever)
2) your batch file (running in a cmd.exe of its own) then does a
#!/bin/bash
$destdir=`perlscript.pl $1`
cd $destdir
exit
I need to clarify one thing. You have to invoke the script with a . infront
of it so that bash will *not* spawn a subshell.
[host:/c]$ . mycd blah
[host:/blah]$
--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede
Quoting O'Reilly book:
Every process[2] has its own current directory. When a new process is
launched, it inherits its parent's current directory, but that's the end of
the connection. If your Perl program changes its directory, it won't affect
the parent shell (or whatever) that launched the Perl
One MORE thing. If u set an alias u can dispense with the . on the command
line. Set an alias like alias mycd='. mycd.sh'. That way the . is taken
care of within the alias and u don't have to type it. The mycd.sh script
can do anything u want to come up with a dir name to cd to.
--
andrew Black wrote:
Hi
I am trying to write a program that will allow me to CD to various
places (more details later). I want to call this from the windows
command line (cmd).
Ways I have tried are
- use Perl chdir - but this only affects the perl process. The
caller doesn't see
$Bill Luebkert wrote:
Did a little searching and came up with this to replace the above 2 lines :
for /F usebackq %%i in (`perl find_dir.pl %1`) do cd %%i
Cheers - that does the trick. I was trying to look for a way of
putting the result of a command into a variable.
A slight refinement
andrew Black wrote:
$Bill Luebkert wrote:
Did a little searching and came up with this to replace the above 2 lines :
for /F usebackq %%i in (`perl find_dir.pl %1`) do cd %%i
Cheers - that does the trick. I was trying to look for a way of
putting the result of a command into
Glenn Linderman wrote:
On approximately 4/19/2005 8:57 AM, came the following characters from
the keyboard of $Bill Luebkert:
...
cd /?
tells about the cd /d option... which changes drives as well as paths...
And yes, that doesn't work on all versions of windows, but neither does