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 cd to this
same directory
3) then cmd.exe exits and drops you back out in the original CMD.exe in its
original working directory because each shell has its own copy which is
propagated to its kids...

on a unix box you'd be tempted just to do: 
        #!/bin/sh
        #mycd.bat
        perl find_dir.pl   %1
      cd  %directory_returned_by_find_dir%
      export $NEWDIR=$PWD       
      exec $SHELL

which probably looks like it works on the surface, but probably doesn't if
you look hard enough (because it starts a new shell) 
You'd achieve this on unix by updating the .bashrc or whatever with a cd
$NEWDIR command however you still get a brand new shell which might not be
any use to you. 

Kind regards,

Mark Anderson
Service Improvement Programme
Level 2, 113 Dundas Street
Edinburgh, EH3 5DE
Tel: 0131 523 8786
Mob: 07808 826 063


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [SMTP:[EMAIL PROTECTED] On Behalf Of
> andrew Black
> Sent: Tuesday, April 19, 2005 9:38 AM
> To:   perl-win32-users
> Subject:      Passing back results to calling command or CD
> 
> *** WARNING : This message originates from the Internet ***
> 
> 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 that change.
>   - write a bat file that calls the Perl which somehow returns the 
> result back to the bat file that can then CD for you.  How can you 
> return this
>      REM  mycd.bat
>      perl find_dir.pl   %1
>      cd  %directory_returned_by_find_dir%
> 
> In a bit more detail as to what I am trying to do at application level.
> I want to be able to type "mycd test" and this looks up test in a flat 
> file and finds
>     test  :  c:\blah\blah\moreblah\test
> and cds you to the correct directory
> 
> Any thoughts as to how to do this
> _______________________________________________
> Perl-Win32-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


The Royal Bank of Scotland plc, Registered in Scotland No. 90312. Registered 
Office: 36 St Andrew Square, Edinburgh EH2 2YB

The Royal Bank of Scotland plc is authorised and regulated by the Financial 
Services Authority and represents The Royal Bank of Scotland Marketing Group. 
The Bank sells life policies, collective investment schemes and pension 
products and advises only on the Marketing Group's range of these products and 
on a With-Profit Bond produced by Norwich Union Life (RBS) Limited.

This e-mail message is confidential and for use by the addressee only. If the 
message is received by anyone other than the addressee, please return the 
message to the sender by replying to it and then delete the message from your 
computer. Internet e-mails are not necessarily secure. The Royal Bank of 
Scotland plc does not accept responsibility for changes made to this message 
after it was sent.

Whilst all reasonable care has been taken to avoid the transmission of viruses, 
it is the responsibility of the recipient to ensure that the onward 
transmission, opening or use of this message and any attachments will not 
adversely affect its systems or data. No responsibility is accepted by The 
Royal Bank of Scotland plc in this regard and the recipient should carry out 
such virus and other checks as it considers appropriate.

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to