Your skill will accomplishwhat the force of many cannot PerlMonks

Re^4: system sub routine with windows7

by marto (Chancellor)
 on Jun 28, 2013 at 13:07 UTC ( #1041249=note: print w/ replies, xml ) Need Help??

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

A couple of things:

my @args = ("c:/glomosim/bin/","data.in");
[download]

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

my @args = ("c:\\glomosim\\bin\\glomosim.exe","c:\\glomosim\\bin\\data
+.in");
[download]

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

Comment on Re^4: system sub routine with windows7
Re^5: system sub routine with windows7
by Njoud (Initiate) on Jun 28, 2013 at 18:39 UTC

Thank you, you are really helpful. But I do not want to run glomosim.exe , what I want is to run the command (glomosim data.in) 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";

[download]

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

Don't worry about it, we're here to help. The weirdness you're seeing "Microsoft windows version..." is the output of running cmd.exe. If you did a Start->Run->cmd.exe then you'd see something like:

Microsoft Windows XP [Version 5.1.2600]

C:\Documents and Settings\marto>
[download]

What you want to do with system is run a comand called glomosim, and pass an input file. So the first part in the example I gave you was to a program called glomosim.exe, if this isn't an executable you need to substite the command with whatever you want to run, not cmd.exe, so the general form of what you want to run is:

my @args = ("c:\\path\\to\\glomosim","c:\\path\\to\\input.file");
[download]

So you need to substite the path to the golomsim program and the path to the input file in the above example. In Re^2: system sub routine with windows7 I give some code to use to produce any errors. I have no idea what glomosim is, how it's executed, but if you substitute these values for the correct paths to the executable and input file we can provide further help if required.

I have misunderstanding :( !. maybe I can't make my question be clear to you. the glomosim is a network simualtor , whatever , when I want to execute the file (data.in). I go to cmd.exe and write the command (glomosim data.in) and press enter. So glomosim here is a command , as you have said, I want to pass this command (glomosim data.in) and run it on cmd.exe from perl. when I write :

@args = ("glomosim", "c:\\glomosim\\bin\\data.in");
system(@args) == 0 or die "system @args failed: \$?";
[download]
I got the error : can't spawn "cmd.exe" : No such file or directory at run_FtpGen.pl line 71 system glomosim c:\glomosim\bin\data.in failed ... I am beginner with perl and using windows7, so sorry for my many questions. :) Thank you

Create A New User
Node Status?
node history
Node Type: note [id://1041249]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-07-31 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?