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
my $hn = qx[c:\\WINDOWS\\system32\\hostname.exe];
works, but
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.
#!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
Solved: Yep, I had a 32 bit perl. So 64 bit programs seem "invisible". I switched to a full 64 bit perl to fix.