Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > directing output of system()

Reply
Thread Tools

directing output of system()

 
 
Murugesh
Guest
Posts: n/a
 
      03-23-2005
Hi all,
when system() is invoked, is there any way to direct the output into
a file.
Thanks
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      03-23-2005
Murugesh wrote:
> when system() is invoked, is there any way to direct the output into
> a file.


May I suggest that you read the documentation for system() instead of
asking hundreds of programmers to read it for you.

perldoc -f system

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
 
Murugesh
Guest
Posts: n/a
 
      03-23-2005
Gunnar Hjalmarsson wrote:
> Murugesh wrote:
>
>> when system() is invoked, is there any way to direct the output into
>> a file.

>
>
> May I suggest that you read the documentation for system() instead of
> asking hundreds of programmers to read it for you.
>
> perldoc -f system
>

In doc, it is said that we can get the exit status of the command.My
question is different.
 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      03-23-2005
Murugesh wrote:
> Gunnar Hjalmarsson wrote:
>> Murugesh wrote:
>>> when system() is invoked, is there any way to direct the output into
>>> a file.

>>
>> May I suggest that you read the documentation for system() instead of
>> asking hundreds of programmers to read it for you.
>>
>> perldoc -f system

>
> In doc, it is said that we can get the exit status of the command.


It also suggests (a couple of sentences later) another method for
running system commands if you are interested in capturing the command's
output.

> My question is different.


Different compared to what?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      03-23-2005
Murugesh <(E-Mail Removed)> wrote:

> when system() is invoked, is there any way to direct the output into
> a file.



Yes, just you would in the shell.


system "ls -l >redirected.file";


Haven't you already tried that?


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Martin Kissner
Guest
Posts: n/a
 
      03-23-2005
Murugesh wrote :
> Hi all,
> when system() is invoked, is there any way to direct the output into
> a file.


Seems quite simple to me (I hope I got you right):

system('command 2>> /path/errors >> /path/results');

Best regards
Martin

--
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'
 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      03-23-2005
Murugesh wrote:

> Hi all,
> when system() is invoked, is there any way to direct the output into
> a file.


Yes - don't use system().

Use backticks, qx(), or open() a pipe to receive the output.

That's if you want to capture the output of the command for use in your Perl
code - if *all* you need to do is direct it to a file, nothing else, then
Tad's suggestion of a simple shell redirect is perfect.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
Murugesh
Guest
Posts: n/a
 
      03-23-2005
Tad McClellan wrote:
> Murugesh <(E-Mail Removed)> wrote:
>
>
>> when system() is invoked, is there any way to direct the output into
>>a file.

>
>
>
> Yes, just you would in the shell.
>
>
> system "ls -l >redirected.file";
> Yes!! I never thought that way! Thanks.
>
> Haven't you already tried that?
>
>

 
Reply With Quote
 
chris-usenet@roaima.co.uk
Guest
Posts: n/a
 
      03-23-2005
Murugesh <(E-Mail Removed)> wrote:
> when system() is invoked, is there any way to direct the output into
> a file.


There are several ways I can think of to do this. One is implied within
the documentation for system() itself.

perldoc -f system
perldoc -f open

Chris
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      03-24-2005
Murugesh wrote:
> Gunnar Hjalmarsson wrote:
>> Murugesh wrote:
>>
>>> when system() is invoked, is there any way to direct the output into
>>> a file.

>>
>>
>> May I suggest that you read the documentation for system() instead of
>> asking hundreds of programmers to read it for you.
>>
>> perldoc -f system
>>

> In doc, it is said that we can get the exit status of the command.My
> question is different.


In which way does the third sentence in the third paragraph of said
documentation _not_ answer your question?

jue


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
J2EE: Directing process output to the client Tim Slattery Java 0 10-16-2007 06:05 PM
directing page output to a New window from server-side? =?Utf-8?B?Q2hyaXNB?= ASP .Net 2 12-09-2006 05:08 AM
Directing a file to the output response... Stu ASP .Net 4 04-27-2006 11:29 AM
Directing Domains Andrew Bonney \(abweb\) ASP .Net 2 11-16-2004 08:07 PM
Re: Directing dynamically generated html content to word from ASP.NET Steve C. Orr [MVP, MCSD] ASP .Net 0 06-03-2004 06:36 AM



Advertisments