Re: How to execute a command line in Perlscript
From: Eric SALGON (eric.salgon_at_mane.com)
Date: 02/06/04
- Next message: Walter Roberson: "Re: how to find the last "new line" in string"
- Previous message: Jeff Thies: "@INC unshift?"
- In reply to: Chris: "Re: How to execute a command line in Perlscript"
- Next in thread: Jürgen Exner: "Re: How to execute a command line in Perlscript"
- Reply: Jürgen Exner: "Re: How to execute a command line in Perlscript"
- Reply: Chris: "Re: How to execute a command line in Perlscript"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 6 Feb 2004 11:17:41 +0000 (UTC)
Unfortunatly, I have implemented "shell" and "puts" functions in my ASP code
but `$_` return no result in @output array with a simple 'dir' command.
I'm afraid it's a problem of right on my IIS server.
Eric
In article <elvUb.19067$Fp6.2360@newssvr16.news.prodigy.com>,
ceo@nospan.on.net says...
>
>Eric SALGON wrote:
>> Hi,
>>
>> Is there someone who knows how to execute a command line (such a simple
echo
>> cmd) in PerlScript.
>>
>> I hve tryed '' or system() but the result is the same: no result but no
error
>> !
>>
>> This syntax works fine in a perl program but not in PerlScript
>>
>> An idea ?
>>
>
>I just realized I didn't answer your question in my last response.
>
>First of all, as a general rule, and one that is outlined in the FAQ
>(and asked about a lot here is) system() does NOT provide output. But
>most especially in the Windows world where Microsoft writes their own
>rules, this is also not the case in either ASP or WSH (still assuming
>you are talking about "PerlScript" and not "Perl script.")
>
>Using output wrappers in the ASP and WSH worlds for outputing a string,
>the following code will work in both worlds for outputing a "system"
>command:
>
>sub shell {
>
> my @output;
> for (@_) { push( @output, `$_` ) }
> chomp( @output );
> return wantarray ? @output : \@output;
>
>}
>
>puts( shell( 'dir /l/on/' ) );
>
>or you can:
>
>puts( shell(
> 'dir',
> 'type c:\\autoexec.bat',
> 'dir c:\\winnt\\system32',
> 'command4',
> 'command5',
>));
>
>If:
>
>ASP: sub puts { for (@_) { $Response->Write( "$_\n" ) } }
>WSH: sub puts { for (@_) { $WScript->Echo( "$_\n" ) } }
>
>Incidentially using PerlScript in Windows allows you this convenience.
>The "official" Microsoft "interface" (read "complicated and
>convolluted") for executing a command in a scripting environment (both
>ASP and WSH) is WshShell.Exec() (which takes two calls to set up.) You
>can do this in PerlScript if you want, but the regular Perl way of
>executing a system command works much smoother.
>
>HTH,
>Chris
>-----
>Chris Olive
>chris -at- --spammers-are-vermen-- technologEase -dot- com
>http://www.technologEase.com
>(pronounced "technologies")
>
>
- Next message: Walter Roberson: "Re: how to find the last "new line" in string"
- Previous message: Jeff Thies: "@INC unshift?"
- In reply to: Chris: "Re: How to execute a command line in Perlscript"
- Next in thread: Jürgen Exner: "Re: How to execute a command line in Perlscript"
- Reply: Jürgen Exner: "Re: How to execute a command line in Perlscript"
- Reply: Chris: "Re: How to execute a command line in Perlscript"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|