Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

'system' call on a different drive

by blacksmith (Hermit)
on Dec 12, 2002 at 05:08 UTC ( [id://219254]=perlquestion: print w/replies, xml ) Need Help??

blacksmith has asked for the wisdom of the Perl Monks concerning the following question:

I know I should be able to figure this one out, but my mind is just stuck. I am running a script on a Win2000 system which has a primary hard drive (c:, naturally) and a secondary hard drive (d:). The script runs from the D:/ command line. It has two "system ()" calls which request commands to be run on the c:/. I am receiving an error "'c:\program' is not recognized as an internal or external command, operable program or batch file.'". I would assume that the reason is that I am unable to go from one drive to the other. Here is part of my code (one of the system calls).
my $downloadbank = "c:/program files/symantec/procomm plus/programs/pw +5.exe bankpull.wax jbankrib.txt"; system ($downloadbank);
Any ideas. Is there a module to help me with this task or am I just coding incorrectly? Thanks. blacksmith.

Replies are listed 'Best First'.
Re: 'system' call on a different drive
by BrowserUk (Patriarch) on Dec 12, 2002 at 05:21 UTC

    You need to quote the spaces in your paths.

    Try

    my $downloadbank = '"c:/program files/symantec/procomm plus/programs/p +w5.exe" bankpull.wax jbankrib.txt';

    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

      Thanks. Such a simple answer to something that has stumped me for about an hour and a half. blacksmith
Re: 'system' call on a different drive
by submersible_toaster (Chaplain) on Dec 12, 2002 at 06:18 UTC

    I recently found that using the multi arg syntax of system negates many of the escaping issues that arise with this command.

    my $pw5 = 'c:/program files/symantec/procomm plus/programs/pw5.exe my $wax = 'bankpull.wax'; my $txt = 'jbankrib.txt'; system ( $pw5 , $wax , $txt ) or die 'Screaming $!';

    Having said that, I have no Win32 system to test this with. But it does a fine job in *nix.

    And if you REALLY get tired of \this \that \" \something else , you will probably find q|singled quoted| and qq|doublequoted| very very helpful.

Re: 'system' call on a different drive
by mce (Curate) on Dec 12, 2002 at 13:11 UTC
    Hi,

    Although it works, I always avoid to use system on win32 systems. Use things like Win32::Spawn, Win32::Process, etc.. from the Win32 module which comes with your windows distribution. It allows better control, error handling, ..
    ---------------------------
    Dr. Mark Ceulemans
    Senior Consultant
    IT Masters, Belgium

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://219254]
Approved by fireartist
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-25 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found