ebcdic has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
Trying to snag a single line from a process, or any output at this point. I have done this before, no biggie, usually.
In a nutshell
works, butmy $hn = qx[c:\\WINDOWS\\system32\\hostname.exe];
my $res = qx[c:\\WINDOWS\\system32\\dsquery.exe computer -name $hn];
Fails with: 'c:\WINDOWS\system32\dsquery.exe' is not recognized as an internal or external command.
Both these programs exist at that location. This is a recent vintage Strawberry Perl (like last week) on Windows Server 2003 64 bit. I am pretty sure it has something to do with 32/64 bits.
How to solve/workaround this? Full test script below.
Solved: Yep, I had a 32 bit perl. So 64 bit programs seem "invisible". I switched to a full 64 bit perl to fix.#!perl my $hn = qx[c:\\WINDOWS\\system32\\hostname.exe]; $hn =~ s/\s+$//; print $hn."\n"; my $res = qx[c:\\WINDOWS\\system32\\dsquery.exe computer -name $hn]; print $res."\n"; __END__ C:\scripts>perl dsquery.pl WWWSERVER006 'c:\WINDOWS\system32\dsquery.exe' is not recognized as an internal or +external command, operable program or batch file. C:\scripts>dir c:\WINDOWS\system32\hostname.exe Volume in drive C has no label. Volume Serial Number is 8065-2993 Directory of c:\WINDOWS\system32 02/18/2007 06:00 AM 10,752 hostname.exe 1 File(s) 10,752 bytes 0 Dir(s) 5,173,231,616 bytes free C:\scripts>dir c:\WINDOWS\system32\dsquery.exe Volume in drive C has no label. Volume Serial Number is 8065-2993 Directory of c:\WINDOWS\system32 02/18/2007 06:00 AM 284,160 dsquery.exe 1 File(s) 284,160 bytes 0 Dir(s) 5,173,231,616 bytes free
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Cannot execute external process
by Old_Gray_Bear (Bishop) on Feb 20, 2014 at 00:47 UTC | |
Re: Cannot execute external process: Win32 Win64 SysWOW64 and System32 redirection
by Discipulus (Canon) on Feb 20, 2014 at 08:36 UTC |
Back to
Seekers of Perl Wisdom