views:

60

answers:

2

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)

+3  A: 

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.

PP
Ok, that sounds promising. Now another big issue: if one of the scripts dies, I want the prompt to remain open to display the error. I looked in the options, but I'm not exactly sure which option would do it, do you happen to know?Also, I need the prompt to be in the same location as the script, not just run it from the current location, should I use the "I" option?
Sho Minamimoto
Maybe you can say `$cmd = "script.exe || cmd.exe";` which would tell windows to run CMD.exe if your script failed. Maybe not be the right approach though.
PP
+1  A: 

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

Use

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

See start /? and cmd /?.

Sinan Ünür