VolatileRig
VolatileRig

Reputation: 2847

How to open a command prompt with Perl?

Ok, read that again. I need to open a windows prompt WITH perl. This is because I want multiple prompts running perl scripts in parallel, but don't want to open them all by hand. So I want a script that I can call (host), tell the number of command prompts to open (clients), path to the client script to run, and even put in inputs if the clients ask. So, two major things:

  1. How to open a prompt with a perl script

  2. How to pass input to that prompt

Thanks! (P.S. I know that it would be a huge mistake to run a host script that calls the same host script, hopefully my boss doesn't do that :P)

Upvotes: 3

Views: 14026

Answers (2)

Sinan Ünür
Sinan Ünür

Reputation: 118138

This is a DOS/Windows question, not a Perl one.

Use

system("start cmd.exe /k $cmd")

See start /? and cmd /?.

Upvotes: 5

PP.
PP.

Reputation: 10864

This might not be a Perl question, so to speak, but a Windows question. I suspect what you want to do is call "start <options> <script>".

For example:

my $cmd = "perl -w otherscript.pl";
my $result = system( "start /LOW $cmd" );

This should start the desired command in a new window and return immediately. Type start /? for other options which can change the new script's priority, hide the next window, or run in the current window.

Upvotes: 6

Related Questions