How to open a command line using Perl?

Ok, read it again. I need to open a Windows WITH perl prompt. This is because I want multiple requests to run perl scripts in parallel, but do not want to open them manually. So I want a script that I can call (host), specify the number of command line prompts to open (clients), the path to the client script to run, and even enter the input if clients ask. So, two main things:

  • How to open request using perl script

  • How to pass input to this prompt

Thank! (PS I know that it would be a huge mistake to run a script host that calls the same script host, I hope my boss does not: P)

+3
source share
2 answers

This is a DOS / Windows issue, not Perl.

Use

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

See start /?and cmd /?.

+5
source

This may not be a Perl question, but a Windows question. I suspect you want to do this: "start <options> <script>".

For instance:

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

This should launch the desired command in a new window and return immediately. Enter start /?for other parameters that can change the new priority of the script, hide the next window or run in the current window.

+6
source

Source: https://habr.com/ru/post/1758863/


All Articles