in reply to Windows System Command

use Win32::ShellQuote qw(:all);

system quote_system( 'C:\Program\ Files\HP Remote System Management\hprsmcli', qw/ -s 143.207.48.60 -u getinfo -p pass / );

Replies are listed 'Best First'.
Re^2: Windows System Command
by Ransom (Beadle) on Jun 27, 2012 at 12:57 UTC
    Seems to be the same solution that BrowserUK offered, just packed in a module. It's a bit overkill for my needs, but thank you.

      Seems to be the same solution that BrowserUK offered, just packed in a module. It's a bit overkill for my needs, but thank you.

      Its not the same, its better. You can use it without ever learning the quoting rules of cmd.exe . You can use it just by learning perl's quoting rules. Its the difference between using a calculator to do multiplication, or pencil and paper :)

      If you're interested see also Behind the GUI lives the Shell and How Command Line Parameters Are Parsed

        We all started with pencils and paper ;) Thanks for the resources!

        Hi, I also have some problem using Perl system call for Windows commands. I used your "system q[]" way to resolve it, but, it didn't work. please see below statement I'm using in my script-

        my $system_error = system q[ "C:\Program Files\Sample\Sample Endpoint +Protection Manager\jre\bin\javaw.exe" -Xms256m -Xmx512m -Dcatalina.ho +me="C:\Program Files\Sample\Sample Endpoint Protection Manager\tomcat +" -Djava.library.path="C:\Program Files\Sample\Sample Endpoint Protec +tion Manager\tomcat\bin;C:\Program Files\Sample\Sample Endpoint Prote +ction Manager\tomcat\webapps\ROOT\WEB-INF\lib;C:\Program Files\Sample +\Sample Endpoint Protection Manager\tomcat\webapps\ROOT\clientpkg\ext +;C:\Program Files\Sample\Sample Endpoint Protection Manager\ASA\win32 +" -jar "C:\Program Files\Sample\Sample Endpoint Protection Manager\bi +n\inst.jar" sca "C:\Compatibility_Automation_Temp\AutoConfig.xml" ]; print "system error for auto config command-if: $system_error\n";

        Output of the above code is: system error for auto config command-if: 256 whereas, when I run this code on cmd directly, it returns me success. please let me know if I'm doing something wrong.