I worte a piece of perl code to run an MSDOS cmd:
The output:
=========
The above code is run on a windows server which has MKStool kit installed and
the partial system info is listed below:
Could someone please tell me what the correct implementation is?
Many thanks.
Code:
my $pp1 = `which powermt`;
chomp($pp1);
my $ret1 = &issue_cmd($pp1, '1st try');
my $pp2 = $pp1;
$pp2 =~ s/\s+/\*/g;
my $ret2 = &issue_cmd($pp2, '2nd try');
my $pp3 = $pp2;
$pp3 =~ s/\\/\//g;
my $ret3 = &issue_cmd($pp3, '3rd try');
my $pp4 = $pp2;
$pp4 =~ s/\\/\/\\/g;
my $ret4 = &issue_cmd($pp4, '4th try');
my $pp5 = $pp2;
$pp5 =~ s/\\/\\\//g;
my $ret5 = &issue_cmd($pp5, '5th try');
sub issue_cmd {
my $cmd = $_[0];
my $flag = $_[1];
print "=============In issue_cmd(), $flag==================\n";
my $ret = `$cmd 2>&1`;
print "\$cmd = $cmd\n";
print "$ret";
print "====================================================\n\n";
return $ret;
}
The output:
=========
Code:
=============In issue_cmd(), 1st try==================
syntax error: got (, expecting Newline
$cmd = C:\Program Files (x86)\EMC\PowerPath\powermt.exe
====================================================
=============In issue_cmd(), 2nd try==================
$cmd = C:\Program*Files*(x86)\EMC\PowerPath\powermt.exe
C:Program*Files*(x86)EMCPowerPathpowermt.exe: not found
====================================================
=============In issue_cmd(), 3rd try==================
$cmd = C:/Program*Files*(x86)/EMC/PowerPath/powermt.exe
C:/Program*Files*(x86)/EMC/PowerPath/powermt.exe: not found
====================================================
=============In issue_cmd(), 4th try==================
$cmd = C:/\Program*Files*(x86)/\EMC/\PowerPath/\powermt.exe
C:/Program*Files*(x86)/EMC/PowerPath/powermt.exe: not found
====================================================
=============In issue_cmd(), 5th try==================
$cmd = C:\/Program*Files*(x86)\/EMC\/PowerPath\/powermt.exe
C:/Program*Files*(x86)/EMC/PowerPath/powermt.exe: not found
====================================================
The above code is run on a windows server which has MKStool kit installed and
the partial system info is listed below:
Code:
OS Name: Microsoft(R) Windows(R) Server 2003 Enterprise x64 Edition
OS Version: 5.2.3790 Service Pack 2 Build 3790
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
OS Build Type: Multiprocessor Free
System Type: x64-based PC
Could someone please tell me what the correct implementation is?
Many thanks.