Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Cannot execute external process

by ebcdic (Initiate)
on Feb 19, 2014 at 23:13 UTC ( [id://1075522]=perlquestion: print w/replies, xml ) Need Help??

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
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.

Replies are listed 'Best First'.
Re: Cannot execute external process
by Old_Gray_Bear (Bishop) on Feb 20, 2014 at 00:47 UTC
    My OS is Windows 7.
    C:\Users\bear>c:\WINDOWS\system32\dsquery.exe 'c:\WINDOWS\system32\dsquery.exe' is not recognized as an internal or +external command, operable program or batch file. C:\Users\bear>
    Doing a quick Google search on dsquery.exe turns up:
    Applies To: Windows 8, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

    Finds users in the directory who match the search criteria that you specify. If the predefined search criteria in this command are insufficient, use the more general version of the query command, dsquery *.

    Dsquery is a command-line tool that is built into Windows Server 2008. It is available if you have the Active Directory Domain Services (AD DS) server role installed. To use dsquery, you must run the dsquery command from an elevated command prompt. To open an elevated command prompt, click Start, right-click Command Prompt, and then click Run as administrator.

    ----
    I Go Back to Sleep, Now.

    OGB

Re: Cannot execute external process: Win32 Win64 SysWOW64 and System32 redirection
by Discipulus (Canon) on Feb 20, 2014 at 08:36 UTC
    Welcome to fraudolent win world! Because you solved it yet only think i can add is a bounch of links (for future monks falling in that pit):

    official docs
    another official doc
    the wiki page

    The worst is that ms apps die with an incredible error like 'there was a problem with..' and fortunately Perl had died with the more useful 'File not found..' error that put me on the rigth path to solve the issue.

    More incredibly there is a workaround! you can use the 'special path' 'sysnative' which is an alias that redirect you where you intend to go. No entries in event log make you aware of the fraud, nor error mentions this.

    hth
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found