Pages

mercredi 28 mars 2012

stderr in csh: how to catch the errors in running csh script

the c-shell is limited to redirect the standard error to a null file. Here is a workaround:


set command =  ls dyd_*
set errors = `sh -c   'ls dyd_*   2> /dev/null'  `
set if_errorexits = `echo $errors | awk '{print length($0)}' `


if ( $if_errorexits == 0) then
     echo "the command does not work"
     exit 1
endif


Aucun commentaire:

Enregistrer un commentaire