Hello everybody,
I am doing some finishing touches to my perl script that is used to telnet into devices and issue some commands.
the problem is that after cold boot some of my devices create slightly different output than after issuing the commands one more time (this is due to different version of system running and I cannot change because they don't have enough resources to run the newer version (that runs on most of my devices and produces output that works fine with my script))
so what I want to do is to run my perl script and redirect all the STDOUT and STDERR to /dev/null and then run my script for the 2nd time and this time it produces valid results and I want to see all the STDOUT and possible STDERR
since the script is the same I would like to perform it via redirection and via modification of my script or having 2 scripts
I cannot fully disclose of that script but it is not necessary I think
in my script I use some "native perl commands" as well as using system() call to execute external shell scripts
when executing the script like this
Code:
perl ./my_script.pl > /dev/null 2 > /dev/null
I achieve redirection of STDOUT and STDERR to /dev/null but only for "native perl commands"
error messages from system() calls are still shown
is there a way of redirecting STDERR from system() as well?
the commands executed using system() are
grep and another
shell script
any advices are appreciated.
thank you very much in advance
//edit:
actually I only want to suppress STDERR from another shell script (that shell script is calling grep)
any ideas?
edit:
//I tried to simulate the issue on my local Linux host (unfortunately I cannot verify it with those devices)
instead of calling it like this ()
Code:
perl ./my_script.pl > /dev/null 2 > /dev/null
I tried calling my local sample like this
Code:
perl ./my_script.pl > /dev/null 2> /dev/null
and now it does not print anything to STDERR
was it that single space in 2 > /dev/null that ruined my attempts to succeed?
I will try it tomorrow but if anybody more experienced could tell me if that new redirection will discard any STDOUT and STDERR messages that my perl script produces
thanks in advance