capturing command-line output in NT - grrr! 
Author Message
 capturing command-line output in NT - grrr!

Hey

This isn't really a perl problem, but I'm encountering it via perl, and
I'm really hoping someone else has run the same thing and knows a good
workaround.

Basically I'm trying to run a command-line program from a perl script
that's called via CGI. and I can't get the frikkin thing to run. i.e.,

$go = `$cmd`;
print("result: $go\n");

and $go will be "". Also if I try system() it'll return 1, and qx// won't
work either.

For simplicity's sake I pointed $cmd to another perl script that just has
a print line within. If I do the same thing as above I get no luck, but if
I change the command line to $go = `perl $cmd`; it'll output OK (and
yes perl is in my path). If I run $cmd from a dos prompt (sans the "perl "
part) it runs OK too. So I'm thinking it might be a permissions thing, but
the everyone user has full control to all the scripts in question.

also if I try to run the original script from a command line it won't
execute $cmd either. "perl -w" gives me no errors.

I saw something yesterday about norton antivirus (which is running on the
machine) mucking with outputs, but I can't re-locate the article, and it
doesn't seem to be an output problem because the script isn't executing in
the first place.

if anyone has seen this before, please, enlighten me!

NT 4.0, service pack whatever's-the-most-recent

Thanks a mil,
chip



Wed, 18 Jun 1902 08:00:00 GMT  
 capturing command-line output in NT - grrr!

Quote:
> For simplicity's sake I pointed $cmd to another perl script that just has
> a print line within. If I do the same thing as above I get no luck, but if
> I change the command line to $go = `perl $cmd`; it'll output OK (and
> yes perl is in my path). If I run $cmd from a dos prompt (sans the "perl "
> part) it runs OK too. So I'm thinking it might be a permissions thing, but
> the everyone user has full control to all the scripts in question.

The WinXX family works a lot with file extensions, rather than using the
'#!' trick
of Unix-like systems.  As far as I know, the only way of reliably executing
Perl
scripts under WinXX is to give them some otherwise-unused file extension
like
".pl", then associate that extension with the Perl interpreter.  This should
produce
scripts that will run in DOS boxes as well as from Start->Run.
==========================================================
Mark Leighton Fisher          Thomson Consumer Electronics

"Browser Torture Specialist, First Class"


Wed, 18 Jun 1902 08:00:00 GMT  
 capturing command-line output in NT - grrr!

Quote:

> Hey

> This isn't really a perl problem, but I'm encountering it via perl, and
> I'm really hoping someone else has run the same thing and knows a good
> workaround.

Actually, there's some material on this in the ActivePerl win32 FAQ..
which is already on your hard drive.  Or wherever you installed Perl.

Quote:
> Basically I'm trying to run a command-line program from a perl script
> that's called via CGI. and I can't get the frikkin thing to run. i.e.,

> $go = `$cmd`;
> print("result: $go\n");

You didn't check the return for errors.  Bad boy!

Quote:
> and $go will be "". Also if I try system() it'll return 1, and qx// won't
> work either.

Well, you checked the return on system() .  That's good.  So it
doesn't work.  Now:

[snip]

Quote:
> also if I try to run the original script from a command line it won't
> execute $cmd either. "perl -w" gives me no errors.

Hey, you used -w !  Excellent!  Look everyone, a poster who does
the right stuff!

Man, where are you most days?  :-)

Just face the fact that a lot of shell conveniences are missing or
broken in win32.  Try

$go = `perl $cmd`;

if you have to.  But you might want to read about do() and require()
to see other ways to use external perl code rather than running it
as an external process.  Type this at a command prompt:

perldoc -f do
perldoc -f require

Oh, and anti-virus programs can do a variety of {*filter*} things to
processes, but this is probably not one of them.

David
--

Senior Computing Specialist
mathematical statistician



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. capturing command line error or output from `<command>`

2. Capturing Command Line Output

3. Output of a command line command

4. capturing output of FILEHANDLE "| command"

5. capturing output from a remote command (how?)

6. Capturing System Command Output with Perl on Windows/Apache

7. capturing output of executed system command

8. capturing output of piped commands

9. Help with Piped command, capturing output

10. Capture command output into list?

11. Capturing output of a system command

12. help with capturing output of open command

 

 
Powered by phpBB® Forum Software