`command 2>&1 > file` without the shell?

K

kj

If I wanted to execute an external (unix) command X such that X's
normal output went to some file, but any error messages from X were
saved to an array, I could, for example, do this:

my @err = `X 2>&1 > some_file`;

How could I achieve the same results without using the shell?

TIA!

kj
 
P

Peter Makholm

kj said:
If I wanted to execute an external (unix) command X such that X's
normal output went to some file, but any error messages from X were
saved to an array, I could, for example, do this:

my @err = `X 2>&1 > some_file`;

How could I achieve the same results without using the shell?

You could use IPC::Open3 and then save the error messages youself.

//Makholm
 
B

Ben Morrow

Quoth kj said:
If I wanted to execute an external (unix) command X such that X's
normal output went to some file, but any error messages from X were
saved to an array, I could, for example, do this:

my @err = `X 2>&1 > some_file`;

How could I achieve the same results without using the shell?

Use IPC::Run.

Ben
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top