directing output of system()

M

Murugesh

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

Gunnar Hjalmarsson

Murugesh said:
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
 
M

Murugesh

Gunnar said:
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.
 
G

Gunnar Hjalmarsson

Murugesh said:
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?
 
T

Tad McClellan

Murugesh said:
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?
 
M

Martin Kissner

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
 
S

Sherm Pendley

Murugesh said:
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--
 
C

chris-usenet

Murugesh said:
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
 
J

Jürgen Exner

Murugesh said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top