LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Supressing shell error message within perl script (https://www.linuxquestions.org/questions/programming-9/supressing-shell-error-message-within-perl-script-856177/)

jeriryan 01-13-2011 04:52 PM

Supressing shell error message within perl script
 
Hi all,

I'm a novice Perl scripter. I need to run a shell command from within my Perl script:
Code:

$deletedev=`echo 1>/sys/block/sdz/device/delete`;
and I can't figure out how to get the error to suppress when sdz doesn't exist. The error is:

Code:

sh: /sys/block/sdz/device/delete: No such file or directory
How can I hide this error?

ForzaItalia2006 01-13-2011 05:38 PM

This error comes from the error stream. You need to capture the output and error stream. There are multiple ways to capture the error stream of a sub-process, e.g. search by "perl external command" (among others).

EDIT: For example, this link.

Hope that helps,
Andi


All times are GMT -5. The time now is 06:46 AM.