Hello Monks, I've stopped in to bother you with another take on what appears to be a common problem in hopes that someone here might have some insight. My OS is Win 2003 Server. First what works:
#! /usr/bin/perl use warnings; use strict; my $test = "/C \"C:\\Program Files (x86)\\Microsoft Office\\OFFICE11\\ +EXCEL.EXE\" C:\\test.xls"; system ("cmd",$test);
No problems here, even with the annoying windows long file name with spaces. The programs starts, the file is loaded, when i close the program I return to the shell and there are no errors. I've been using system this way for a long time and never seen a problem. Of course this is a gui program and doesn't even require cmd, so maybe in some weird way it's skipping right over it. However I can successfully run all kinds of cmd programs, for example:
my $testfile = "fromdos"; my $test = "/C ${testfile} test.txt"; system ("cmd", $test);
Now what doesn't work:
#! /usr/bin/perl use warnings; use strict; my $testfile = "resultset.exe"; my $test = "/C ${testfile} localhost root pwd"; system ("cmd", $test);
Now when this fails I get the classic "Can't spawn "cmd": Bad file descriptor at temp2.plx line 11." Line 11 being the system call. The test executable is in the directory with the perl script which calls it, and it requires the arguments listed in order to run. Run it does. However after the expected output I get the error. Even more strange is when I do this I get the same error:
my $test = "${testfile} localhost root pwd"; system ($test);
In this case I'm not even asking it to start cmd.exe, but yet it's telling me that it can't spawn it. Again, the executable runs and gives me it's output, but then I get the error. cmd.exe is in system32 where it should be and system32 is in my path (proven by the fact that the first code ran fine). The executable is in the same directory as this perl script. Thinking that this might be some weird sort of 32/64 bit issue, I also tried running it like this:
my $test = "/C ${testfile} localhost root pwd"; system ("C:\\WINDOWS\\SysWOW64\\cmd.exe", $test);
Same exact results. Anyone have a clue what is going on here? I think I've gone through all the usual suggestions concerning the path env and the windows/linux path variations. Nothing seems to change this behavior, and I think my first example bears out the fact that neither of these things are at the root of this. Thanks a Bunch

In reply to Can't spawn "cmd.exe": by emalossi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.