Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

selecting specific command prompt from multiple command promt

by ayush (Initiate)
on Dec 26, 2013 at 12:04 UTC ( [id://1068423]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monks,

I am trying to write a perl script that would access and execute command in another command prompt.

Explanation: Windows command prompt 1 is executing a perl script , and executes a system command that opens another command prompt ,with some set environment variables , now once the other prompt is opened i want to execute different sequence of commands in the newly opened prompt,

Is there any way where i can search process (in this case a command prompt) , and then input that process with a .bat file,

Tried something like

$pid = open("$nameofprompt" , "|$args"); but NO luck,

unfortunately the platform is windows, any kind of help would be a help,

thanks .

Replies are listed 'Best First'.
Re: selecting specific command prompt from multiple command promt
by ww (Archbishop) on Dec 26, 2013 at 12:16 UTC
    I'm not sure this is a Perl question: can you do what you've described from the CLI?

    If so, system or backticks might offer an approach whereas open is -- as perldoc -f open will tell you -- for opening a file; not for executing it.

    If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.
Re: selecting specific command prompt from multiple command promt
by VincentK (Beadle) on Dec 26, 2013 at 15:33 UTC
Re: selecting specific command prompt from multiple command promt
by jellisii2 (Hermit) on Dec 26, 2013 at 15:17 UTC
    This smacks of an XY Problem. Can you bring the problem up one level?
Re: selecting specific command prompt from multiple command promt
by Laurent_R (Canon) on Dec 26, 2013 at 16:14 UTC
    Hi, not really sure what you want to do, but you can definitely launch another command prompt process from your Perl script, including launching a command.bat or another Perl script within that new command prompt. For example:
    # Outer Perl script # do something and set $arg to something my @inner_script_result = `perl ./inner_script.pl $arg`; # ...
Re: selecting specific command prompt from multiple command promt
by renegadex (Beadle) on Dec 27, 2013 at 01:30 UTC
    Hey buddy,
    I had this same project way back before, check out my post, It got answered.
    http://perlmonks.org/?node_id=1064931
    I wanted to be able to run 2 cmd.exe in the background that I can continuously monitor, and occassionally send commands to any of the 2 cmd.exe and read its output (reply) when it replies. I hope this helps!
    Mabuhay Civil Engineers! :D

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-24 19:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found