Oops...forgot something... ----direct.bat--- cd %1 ----direct.bat---
Or: #!perl -w $chdir = "c:\\winnt"; #or whatever code you want to pick a directory system("start /B cd $chdir"); #go to that directory I also found some strange side effects...typing "cd \" (since I put my test script in my root dir) and "perl direct.pl" gives an error on subsequent executions: C:\>perl direct.pl Can't open perl script "direct.pl": No such file or directory ... -----Original Message----- From: Stovall, Adrian M. Sent: Wednesday, September 25, 2002 10:03 AM To: '[EMAIL PROTECTED]' Subject: RE: Setting the actual directory with a Perl script. That took a bit of thinking...Three lines: #!perl -w $chdir = "c:\\winnt"; #or whatever code you want to pick a directory system("start /B direct.bat $chdir"); #go to that directory Sometimes it's easier to lean on dos commands than on perl commands (not very often, though). :) HTH Adrian ----cwd.bat---- -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 8:44 AM To: [EMAIL PROTECTED] Subject: Re: Setting the actual directory with a Perl script. Hello, thats not exactly the behaviour I wanted. Its a little bit complicated, because instead C:\>test_cd.pl C:/ C:/ c:/temp C:\> I want to have C:\>test_cd.pl C:/ C:/ c:/temp C:\temp\> (using your code as test_cd.pl). Regards, Martin Kellner |--------+-----------------------------------------------> | | "Stovall, Adrian M." | | | <[EMAIL PROTECTED]> | | | Gesendet von: | | | [EMAIL PROTECTED]| | | eState.com | | | | | | | | | 25.09.2002 15:33 | | | | |--------+-----------------------------------------------> >----------------------------------------------------------------------- ---------------------------------| | | | An: <[EMAIL PROTECTED]> | | Kopie: | | Thema: RE: Setting the actual directory with a Perl script. | >----------------------------------------------------------------------- ---------------------------------| That won't quite work... #!perl -w use Cwd; print cwd."\n"; #print the starting directory system("cd c:\\temp\\"); #use the system "cd" command print cwd."\n"; #print the current directory (didn't change) chdir("c:\\temp\\"); #change to c:\temp (insert the directory name of your choice) print cwd."\n"; #print the current directory (changed as expected) Above is an example of what using the system "cd" command does. If you want to change the working directory of your perl script, use perl's chdir() function. -----Original Message----- From: Adam Ingerman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 8:05 AM To: [EMAIL PROTECTED] Subject: Re: Setting the actual directory with a Perl script. >Hello, > >do you know a possibility to set the actual directory inside a Perl >script ("chdir my_dir;") to get it changed in the command shell outside >the script? > >setDir.pl: > # some code to set $MyDir > chdir $MyDir; > exit 0; >Command line: > > setDir.pl > >Regards, > Martin Kellner > easiest way, tell the shell to do it for you. if you're on windows, #---code-- system("cd c:\\windows\\"); #-- snip you can of course use a variable for your directory. and if you're using a different OS, or even if you have something better, like for example you want to use "cdd" or whatever, changing is easy. the system() command just executes a command on the shell. _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs