Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: system sub routine with windows7

by marto (Bishop)
on Jun 28, 2013 at 09:36 UTC ( #1041202=note: print w/ replies, xml ) Need Help??

in reply to Re: system sub routine with windows7
in thread system sub routine with windows7

Your example doesn't match mine exactly. Try:

#!/usr/bin/perl use strict; use warnings; my @args = ("glomosim", ""); 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.

Comment on Re^2: system sub routine with windows7
Download Code
Replies are listed 'Best First'.
Re^3: system sub routine with windows7
by Njoud (Initiate) on Jun 28, 2013 at 12:30 UTC

    I have put on the begining of .pl file :

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

      A couple of things:

      my @args = ("c:/glomosim/bin/","");

      Here you provoide a directory, but not the name of the executable you want to call. Also if you have the file within the bin directory you'll need to do:

      my @args = ("c:\\glomosim\\bin\\glomosim.exe","c:\\glomosim\\bin\\data");

      Note that in both occasions I provide the full path to the file, and use \\ rather than / as the path separator. As a piece of general advice, the easiest way to get help with errors is to post the erros along with the code which generates them. How do I post a question effectively? has some great advice on posting. Let me know if you have further problems

        Thank you, you are really helpful. But I do not want to run glomosim.exe , what I want is to run the command (glomosim on CMD.exe ! So I tried to write :

        my @args = ("c:\\Windows\\System32\\cmd.exe","c:\\glomosim\\bin\\data. +in"); system(@args) == 0 or die "system @args failed: \n syscode:$? \ +n error:$! \n";

        but I get nothing !! Microsoft windows version ..... etc ! How I can pass a command (glomosim to cmd.exe ? Thank you very much.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1041202]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-11-25 06:40 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (671 votes), past polls