![]() |
| ||
| In perl script system("cd c:\mnt"); is not working. i m using perl script to do something where i want to change my current directory to mnt in c: only.. bt using function system("cd c:\mnt"); is nt working. system("dir"); is working properly ,also some other command using systems function in perl script is working fine bt dnt know what problem it is having with cd. I also tried to change the drive c: to z: system("z:"); bt its nt working. these commands are working properly on command prompt bt nt in perl script. even i used `cd c:\mnt` ,tried all combination with the `` but its nt doing. can someone please help me????????? its very urgent.. Thanks in advance for ur reply and also giving ur valuable time.. Waiting for reply..specially i hv joined this forum for this query i m nt getting its answer..plz help me. |
| ||
| Re: In perl script system("cd c:\mnt"); is not working. Each system command gets it's own "shell" (if you want to call it such, it's not really a complete shell, but it is an executiuon environment). So, the cd is working, but it's happening within that subshell, which means the shell in which the perl script itself is running, remains unchanged. Use the chdir function. |
| ||
| Re: In perl script system("cd c:\mnt"); is not working. Thanks a lot for ur reply.. I tried using chdir also bt no use. what i tried is , system 'chdir /D c:\\mnt'; system("chdir c:\\mnt"); even simply chdir (c:\mnt); chdir('c:\mnt'); `chdir c:\\mnt`; bt its not responding... what can be the reason???? I really need this to use in my code... my complete script is, =comment use Win32::OLE; $b = Win32::OLE->new('imacros') or die "iMacros Browser could not be started by Win32:OLE\n"; $b->{Visible} = 1; $b->iimInit(); my $macro = "mount_share"; $b->iimPlay($macro); $b->iimExit(); system("net use \\\\192.168.30.62\\share1 u1 /USER:u1"); system("net use c:\mnt \\\\192.168.30.62\\share1"); =cut #@args=("cd", "c:\\mnt"); #system(@args); print "cd c:\\mnt"; #system 'chdir /D c:\\mnt'; `chdir c:\\mnt`; part which i hv commented is working nicely....bt stucked to that chdir part only.... thanks to give ur valuable time... |
| ||
| Re: In perl script system("cd c:\mnt"); is not working. I said chdir function. Don't use the system function to do this, use the chdir function. http://perldoc.perl.org/functions/chdir.html |
| ||
| Re: In perl script system("cd c:\mnt"); is not working. try this, note the single-quotes: chdir('c:\mnt') or die "Can't chdir to c:\\mnt : $!"; see if die returns an error. Its actually better to use forward slashes even with windows, which fully supports their use in directory paths. chdir('c:/mnt') or die "Can't chdir to c:/mnt : $!"; That way you avoid using perls escape operator \ in the wrong context in your perl code, like you did here: chdir("c:\mnt"); which interpolates as: chdir(c:nt); or if the sequence \m is a valid meta character sequence perl would expand that into whatever it is (if anything). Like \t is a tab inside a double-quoted string. |
| ||
| Re: In perl script system("cd c:\mnt"); is not working. If its a mapped drive it may fail. I'm Not sure how you get perl to recognize a mapped drive. Maybe masijade will know. |
| ||
| Re: In perl script system("cd c:\mnt"); is not working. Quote:
|
| ||
| Re: In perl script system("cd c:\mnt"); is not working. I use perl on Windows daily. If it is a mapped drive it will not fail. the file system functions work perfectly (chdir, copy, mkdir, etc.) on Windows but you have to either use a front slash (as you suggest above) or a double backslash if you are using double quotes. So: $dir="d:\\somedir\\somesubdir"; Should work fine. |
| All times are GMT -4. The time now is 4:58 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC