Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Windows "Bad File Descriptor" problem

by HuckinFappy (Pilgrim)
on Sep 26, 2006 at 16:40 UTC ( [id://574978]=perlquestion: print w/replies, xml ) Need Help??

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

Brethren help me!

Following the latest round of Windows Security Patching, as mandated and inflicted on us by the I.T. group, we have begun to get erratic failures in one of our scripts which appear as:

Can't spawn "C:\WINDOWS\system32\cmd.exe": Bad file descriptor
The line in question is:
my $_retVal = system $ENV{ ComSpec }, '/c', $_fullCmd ;
Where $_fullcmd is simply the path to another script.

A given machine might execute this line fine many times, then will issue this error repeatedly over a period of a few minutes, before maybe working again. There appears to be no consistency.

I'm hoping someone else may have seen this...

thanks,
~Jeff

Replies are listed 'Best First'.
Re: Windows "Bad File Descriptor" problem
by liverpole (Monsignor) on Sep 26, 2006 at 17:03 UTC
    Hi HuckinFappy,

    Very simple -- you want to concatenate the strings instead:

    my $_retVal = system $ENV{ ComSpec }. '/c'. $_fullCmd ;

    I think your mistake was that you're used to printing strings that way (ie. by separating arguments with commas), but for system, of course, you need a concatenated string.

    Update:  After I thought about that for a minute, I realized it shouldn't make a difference.  But of course someone else had already beaten me to that conclusion.  Please ignore my erroneous advice above, and give your ++ votes to runrig instead.  :-(


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
      If you read the docs for system, you'll see that system LIST is fine.
Re: Windows "Bad File Descriptor" problem
by Argel (Prior) on Sep 26, 2006 at 21:58 UTC
    I'm not sure what is really going on but one thought is file descriptors are not being freed up (or are not being freed up fast enough). Are you running multiple instances of this script?

    My other thought would be an issue with either the ComSpec enivonment variable or with $_fullCmd. To help rule this out you could store everything in a string (or array), print it out, and then pass it to system.

    Also, you should be able to look at your system or application event logs to find out which patches were actually installed and see what Technet or the KB says about them. If the system was rebooted after the patches were applied then it is also possible the cause is not related to the patches (i.e. something was changed but the change did not ake effect until after the reboot). If they were not rebooted after the patches then you might want to consider that (espcially if Microsoft recommends it).

Re: Windows "Bad File Descriptor" problem
by Anonymous Monk on Sep 27, 2006 at 10:53 UTC
      Thanks, I've read all of those:
      'can't spawn nowait'
      This involved the spawned process returning a negative value. This is not the case, as the script we are spawning can not return negative.
      Can't spawn "cmd.exe": No error at
      This talks about perl depending on your path to find cmd.exe, or spaces in the filenames, neither of which seem to apply to this problem. IAC, it discusses the "No such File or Directory" error, not "Bad File Descriptor"
      system command can't spawn cmd.exe
      This one doesn't contain anything relevant, nor does the OP know how his problem cleared up. And again, the error is different.
      system command erroneously states 'can't spawn <executable>'
      Completely unrelated.

      None of those threads seem to be related to what I am seeing. I'm still pursuing the Windows Patch angle. Apparently some of our machines have patches installed that I.T. can't explain how they got on there. Out of a pool of 30 machines, I have 4 that exhibit this problem sporadically, so I'm focusing on those 4 now.

      Thanks

        hi HuckinFappy
        I'm seeing the same error while usinf file::copy
        I'm reading from a list twice the same file name.
        once it's OK and the second gets an error.
        however the file is being copied.
        Plus this happen to only one file out of the whole list.

        Moked

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://574978]
Approved by grep
Front-paged by xdg
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found