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

Re: executing commands in cmd using perl

by atcroft (Abbot)
on Dec 30, 2014 at 16:22 UTC ( [id://1111738]=note: print w/replies, xml ) Need Help??


in reply to executing commands in cmd using perl

My first stop would be system or exec-the former returns from the command, the latter turns control over to the process being executed and does not return to the script. If you are wanting the script to do control the process, or to process the output, then perhaps a read of the IPC (inter-process communications) doc would be informative. (You may also want to review the perlsec document, to be aware of possible areas of concern if you are dealing with potentially untrustworthy data.)

Hope that helps.

Update: 2014-12-30
s/possibly (untrustworthy)/potentially $1/

  • Comment on Re: executing commands in cmd using perl

Replies are listed 'Best First'.
Re^2: executing commands in cmd using perl
by Sudhk (Initiate) on Dec 30, 2014 at 17:04 UTC
    I have to first open cmd.exe and then execute command in cmd ,could you give me a small example please .
      If I'm understanding what you are asking (which seems unusual), your query is answered at stackoverflow. Example
      system 'start cmd.exe @cmd /k "Command"';
      Of course, that second bit isn't actually a Perl question.

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Are you sure you need to open cmd.exe and then execute a command in it? Perl can issue a command to windows, even run a dos/windows .bat file without having to run cmd.exe. Perhaps you should tell a bit more specifically what you want to do rather than asking us how to do it the way you think it might be done. This looks like a case of XY Problem.
        You are right man.But thanks for the support of the perl monks community I got the work done.In future before asking something from you guys I will take care of the xy problem that you mentioned.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-24 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found