Running a batch file from Perl (Activestate perl in Windows)
Posted
by Jithesh
on Stack Overflow
See other posts from Stack Overflow
or by Jithesh
Published on 2010-05-25T18:43:30Z
Indexed on
2010/05/25
18:51 UTC
Read the original article
Hit count: 596
perl
I have a Perl program which does something like below:
#!perl
use strict;
use warnings;
my $exe = "C:\\project\\set_env_and_run.bat";
my $arg1 = "\\\\Server\\share\\folder1";
my $arg2 = "D:\\output\\folder1";
my $cmd = "$exe \"$arg1\" \"$arg2\"";
my $status = system("$cmd > c:\\tmp\out.txt 2>&1");
print "$status\n";
I am calling this Perl code in an eval block. When invoked, i get the status printed as 0, but the batch file has not actually executed. What would be the reason for this?
Thanks, Jits
© Stack Overflow or respective owner