Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Problems? Is your data what you think it is?
 
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 ( #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...


Comment on Re: qx vs WScript: Why didn't qx work in my ActiveState's PerlScript?
Select or Download Code
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
Node Status?
node history
Node Type: note [id://197090]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-04-24 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (565 votes), past polls