Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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...

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
Node Status?
node history
Node Type: note [id://197090]
help
Chatterbox?
[stonecolddevin]: i will admit i find the responses to his threads incredibly entertaining
[stonecolddevin]: erix what is this wizardy? there's no sound for me :-(
[stevieb]: he comes and goes every few years.
[erix]: stonecolddevin: oh? Don't know, it works for me
[Sinistral]: stonecolddevin / stevieb - would 'he' in this context (looked at last 50 lines and didn't see discussion) be a certain solar timepiece user?
[stonecolddevin]: Sinistral yes indeed
[Discipulus]: he does not learn, nor teach, nor learn
[planetscape]: hello all

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2017-06-22 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (529 votes). Check out past polls.