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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.