Would like to make a system call without displaying msg to STD OUT

D

desert.fox11

Hi,
I'll try to say this succinctly. I make a call using system "unzip -o",
"$filename" which calls a utility unzip that has 'status' messages
display to std out. This is fine, however, can I re-direct ( or at the
very least suppress ) these messages.
eg. " Inflating README.txt........"
Any suggestion is appreciated.
 
J

John W. Krahn

I'll try to say this succinctly. I make a call using system "unzip -o",
"$filename" which calls a utility unzip that has 'status' messages
display to std out. This is fine, however, can I re-direct ( or at the
very least suppress ) these messages.
eg. " Inflating README.txt........"
Any suggestion is appreciated.

perldoc -q "How can I capture STDERR from an external command"


John
 
A

Anno Siegel

Hi,
I'll try to say this succinctly. I make a call using system "unzip -o",
"$filename" which calls a utility unzip that has 'status' messages
display to std out. This is fine, however, can I re-direct ( or at the
very least suppress ) these messages.
eg. " Inflating README.txt........"
Any suggestion is appreciated.

Look for -q in man zip.

Anno
 
J

Jürgen Exner

I'll try to say this succinctly. I make a call using system "unzip
-o", "$filename" which calls a utility unzip that has 'status'
messages display to std out. This is fine, however, can I re-direct

On most command shells that I know about you can use the ">" to redirect
stdout into a file. Just redirect it to /dev/null
(or at the very least suppress ) these messages.

Typically that question would be answered in the documentation of the tool
that you are using.
Many applications have an option like "-s" for silent or similar.

Now, what's your Perl question?

jue
 
T

Tad McClellan

Hi,
I'll try to say this succinctly. I make a call using system "unzip -o",
"$filename"


perldoc -q vars

which calls a utility unzip that has 'status' messages
display to std out.


Is that really what your system() call looks like?

It is a strange hybrid of the one arg form:

system "unzip -o $filename"

and the LIST form

system "unzip -o", $filename

where the list form attempts to run a command whose name is
eight characters long.

The proper LIST form would be something like:

system 'unzip', '-o', $filename

This is fine, however, can I re-direct ( or at the
very least suppress ) these messages.


You can use shell redirection with the one arg form:

system "unzip -o $filename >/dev/null"
 
B

Bart Lateur

I'll try to say this succinctly. I make a call using system "unzip -o",
"$filename" which calls a utility unzip that has 'status' messages
display to std out. This is fine, however, can I re-direct ( or at the
very least suppress ) these messages.
eg. " Inflating README.txt........"
Any suggestion is appreciated.

Perhaps you are actually interested in reading those messages into your
program. The simplest way to achieve that, is to use backticks
("`command`"), AKA qx. See "qx" in perlop.

But that'll wait till the program is finished before returning. If you
want an intermediate update, you can call

open STATUS, "command |";

and read the output from the command through ordinary readline calls.

while(<STATUS>) { ... }

If you still want more, like piping into the command's STDIN or read its
STDERR separately, check out the modules IPC::Open2 and IPC::Open3. Both
come with Perl.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top