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

Re: qx vs WScript: Why didn't qx work in my ActiveState's PerlScript?

by jkahn (Friar)
on Sep 11, 2002 at 21:52 UTC ( [id://197090]=note: print w/replies, xml ) Need Help??


in reply to qx vs WScript: Why didn't qx work in my ActiveState's PerlScript?

strictly as a guess, I suspect that it's the behavior of qx/ls/ that you don't fully understand.

qx/ls/ really is telling Perl "drop to a shell and execute the command 'ls', and return the results."
That does the same thing that the Win32::Script module does but only when you have ls available as a tool!

On a virgin client Windows machine, you may not have ls available -- I have it on all my systems, because I use Cygwin for nearly everything, but your boss (or your boss's boss) probably doesn't have ls available as a tool on his or her desktop.

hmm... on reading back through your question, you say that redirecting the output of ls into a text file actually does create a text file. If my suggestion is right, it would be an error message, not the actual results. Perhaps I'm completely off after all...

Replies are listed 'Best First'.
Re: Re: qx vs WScript: Why didn't qx work in my ActiveState's PerlScript?
by dws (Chancellor) on Sep 11, 2002 at 22:05 UTC
    I suspect that jkahn is correct. In light of that, you might consider a "pure Perl" solution. Instead of using "ls" (or "dir"), use a combination of opendir(), readdir(), stat(), and closedir() to effect the directory listing. You might also need a chdir() to ensure you're in the right starting place; web servers are notoriously inconsistent about what working directory they use for scripts.

      Sorry for the confusion :p... I meant to use "ls" merely as a generic example. (Maybe I should use "foo"?)... Besides, I do have ls.exe on my Windows (Windows-port of Unix tools). Thanks.
        Yes, but if you are running this from a browser, you are not running as yourself, but as httpd or whatever your web server calls itself on your platform. This user has an empty path and to use a program such as ls.exe, you must give it the full path to it. It may also not have the rights to execute the program

        Regards,

        Helgi Briem

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-23 11:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found