By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,670 Members | 1,462 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,670 IT Pros & Developers. It's quick & easy.

How to execute multiple commands through perl script

P: 1
Hello,

I am trying to use perl to run two different commands - both of which need to be executed in a separate command prompt.

Here are some of the details:

when I run

system('start cmd /k "cd c:\PerlExamples && perl Perl_Ex_1.pl"');

it works as expected - it opens a new command prompt, paths to the directory I need and runs my script.

However, I want to use this system... command in a loop where each time I am running a different example script.
But when I run the following lines of code,

my $cmd = "perl Perl_Ex_1.pl";
system("start cmd /k cd c:\PerlExamples && $cmd");

it opens a new command prompt and paths to the directory I need. But it runs my example script in the original window and not in the newly opened command prompt.

Is there a way for me to do this?

Thank you.
Oct 4 '16 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 100+
P: 589
Cross posted and answered on perlmonks.
Oct 4 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.