in reply to Re^2: Windows System Command
in thread Windows System Command

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

Replies are listed 'Best First'.
Re^4: Windows System Command
by Ransom (Beadle) on Jun 27, 2012 at 14:47 UTC
    We all started with pencils and paper ;) Thanks for the resources!
      We all started with pencils and paper ;)

      Unfortunately, and awful lot of programmers these days don't.

      They build complicated systems by gluing (and tacking and forcing-fitting), a bunch of modules they never look inside and wouldn't (attempt to) understand if they did.

      And when they need slight variations of functionality, they seek out yet another module to wrap around the first to bend its output to what they want. The result is they end up with slow, heavy, OO-tagliatelle behemoths that sap 10 times as many cycles to do anything than is necessary.

      Then they are forced to seek to mitigation for that, by wrapping it in yet another layer to distribute it across a cluster because single boxes are too slow.

      {sigh} My gray hairs are showing again :)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

Re^4: Windows System Command
by Anonymous Monk on Aug 08, 2012 at 09:25 UTC

    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.

      Try putting the command into a .bat file; and then invoke that bat file from Perl using system.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        Hi, no improvements. Still the same error :(
        Hi, I got this. But, still, return value of this command is 1 (256/256). That is the failure code on cmd. It means, my command is failing when I'm running it using system command. How to resolve it.

      How to resolve this issue?

        Did you read the links here?