Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Windows start /min

by bdungy (Initiate)
on Apr 18, 2007 at 19:54 UTC ( #610831=perlquestion: print w/replies, xml ) Need Help??

bdungy has asked for the wisdom of the Perl Monks concerning the following question:

I'm relatively new to Perl and I'm trying to use the system() call to run "start /min xxxx" from my Windows environment. However, the system command seems to keep converting the /min into \min. Is there anyway to prevent it from doing that?

Replies are listed 'Best First'.
Re: Windows start /min
by Corion (Pope) on Apr 18, 2007 at 20:14 UTC

    I can't confirm that:

    perl -le "system('start /min cmd.exe')" # starts a minimized command window, just as expected # This is perl, v5.8.5 built for MSWin32-x86-multi-thread

    So maybe show us your code - you get bonus points if you can reduce it to the following four lines:

    my $cmd = "..."; # this is the important part you have to supply print "Trying to launch '$cmd'\n"; system($cmd) == 0 or warn "Couldn't launch '$cmd': $!/$?";
Re: Windows start /min
by ikegami (Pope) on Apr 18, 2007 at 20:39 UTC

    I tried to reproduce your problem in Win2k with ActivePerl 5.6.1 and on WinXP with ActivePerl 5.6.0, 5.6.1, 5.8.0 and 5.8.8 using

    perl -e "system('start /min notepad');"

    but it worked fine every time. Could you provide more info, such as the code you are using?

      $ perl -e 'system("cmd /c start /min notepad") and die $!;'
      works with Cygwin's Perl. (But note the required "cmd /c")

      Search, Ask, Know

        I am having trouble with the "start" command.

        Here is the contents of the PERL5SHELL environment variable:

        c:\>echo %PERL5SHELL% cmd.exe /c
        Calling the "dir" command works fine:
        c:\>perl -e "system(\"dir\")" Datenträger in Laufwerk C: ist SYSTEM Volumeseriennummer: CA02-1E1F Verzeichnis von c:\ 03.08.2012 14:24 <DIR> cygwin 09.10.2012 18:01 <DIR> Daten ... 10.10.2012 08:59 <DIR> Windows 2 Datei(en), 15.460 Bytes 15 Verzeichnis(se), 144.527.847.424 Bytes frei
        Calling "start dir" from Perl does not work:
        c:\>perl -e "system(\"start dir\")" start: dir: Das System kann die angegebene Datei nicht finden.
        Calling "start dir" directly opens a new window with the output from above:
        c:\>start dir
        Any idea what might cause this behaviour??



Re: Windows start /min
by Moron (Curate) on Apr 18, 2007 at 20:18 UTC
    Although it usually works to put the command and its arguments in the first argument to system(), the dedicated place to put arguments (that therefore won't get treated as a filename which needs slash-bending for windows) is in the second argument to system() - the parameter list. See system for the exact syntax of a two-argument call.

    ^M Free your mind!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://610831]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2019-10-20 05:45 GMT
Find Nodes?
    Voting Booth?