Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

system sub routine with windows7

by Njoud (Initiate)
on Jun 28, 2013 at 09:00 UTC ( [id://1041189]=perlquestion: print w/replies, xml ) Need Help??

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

I want to execute the following command on cmd.exe from perl : "glomosim data.in" For that I write the following:

 system(glomosim data.in);

But it doesn't work .I am using windows7 and I am begginer with perl, So how i can use system subrotine with windows 7 ?

Replies are listed 'Best First'.
Re: system sub routine with windows7
by marto (Cardinal) on Jun 28, 2013 at 09:14 UTC
Re: system sub routine with windows7
by kcott (Archbishop) on Jun 28, 2013 at 09:10 UTC
Re: system sub routine with windows7
by hdb (Monsignor) on Jun 28, 2013 at 09:08 UTC

    For one it would be useful to see the error message. Also, as a minimum, you would need quotes around the command.

    system("glomosim data.in");
Re: system sub routine with windows7
by Njoud (Initiate) on Jun 28, 2013 at 09:28 UTC

    Thank you for your replay I write the following as you have mentioned :

    my @args = ("glomosim data.in"); + system(@args) == 0 or die "system @args failed: $?";

    So I get the following error : system glomosim data.in failed :65280 at run_Ftp.pl line 68. what I can do else ?!

      Your example doesn't match mine exactly. Try:

      #!/usr/bin/perl use strict; use warnings; my @args = ("glomosim", "data.in"); system(@args) == 0 or die "system @args failed: \n syscode:$? \n error +:$! \n";

      ensure the location of glomosim is in your system PATH variable, or provide full paths to both the program and the input file. Also, you replied to yourself rather than anyone else. See the links I provided earlier.

        I have put on the begining of .pl file :

        use strict; use warnings; ......
        I have a file with name (data.in) in the path (C:\glomosim\bin) which I want to execute it on cmd.exe using the command (glomosim data.in) where "glomosim" is a keyword to execute the file (glomosim is a NW simualtor). So I write the following :
        my @args = ("c:/glomosim/bin/","data.in"); system(@args) == 0 or die "system @args failed: \n syscode +:$? \n error:$! \n";
        then many errors appear :( ! Plz I need a help really!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-19 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found