Suppressing error msgs from cmd-line.

L

Lax

Hello all,
From my Java program, I'm constructing a cmd-line one-liner and
running it from the shell on various platforms.

Is there any platform independent way to suppress error messages from
the cmd-line?
e.g., if the program does a "ls somefile.txt" on Unix and an analogous
"dir somefile.txt" on WIN, I want to suppress the error msgs, if
somefile.txt is not present.

In Unix, I could do a "ls somefile.txt 2> /dev/null".
But, is there a platform independent way to do the suppression.

Alternatively, how does one suppress the error msgs from WIN cmd? :)

Thanks for your time,
Prab
 
J

Johan Poppe

Lax skrev:
e.g., if the program does a "ls somefile.txt" on Unix and an analogous
"dir somefile.txt" on WIN, I want to suppress the error msgs, if
somefile.txt is not present.

In Unix, I could do a "ls somefile.txt 2> /dev/null".
But, is there a platform independent way to do the suppression.

Yes: Write a Java program :)
Alternatively, how does one suppress the error msgs from WIN cmd? :)

dir somefile.txt 2> nul

(I'm not quite sure if error redirection works on win95)
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top