ls redirection

Jay A. Konigsberg jak at sactoh0.SAC.CA.US
Wed Sep 5 00:45:32 AEST 1990


In article <90245.224246SML108 at psuvm.psu.edu> SML108 at psuvm.psu.edu (Scott the Great) writes:
>Hi, I am using system(command) to call ls and get a file listing which
>I re-direct to a file.  This works rather well, but if no match is found,
>an error is reported to the calling shell.  Is there any way to suppress
>this error reporting?

Yes.

Though I don't know how your getting this to a file, I'll assume your
either using the '>' shell operator rather than the dup(2) system call.

system("ls 1>/tmp/file 2>/dev/null");

this redirects stdout to the file and stderr to the system trash can.

However, depending on exactly what your doing, you may want to look into
using dup(2). I'm not completly sure how it would work, but then I just
figured out why dup(2) is useful.

-- 
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
If something is worth doing, its worth doing correctly.



More information about the Comp.unix.questions mailing list