The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: Error Messages
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-26-2005
akrathi akrathi is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 41
Error Messages

I have got script like this
#!/bin/ksh -e
function errtrap {
es=$?
print "ERROR line $1: Command exited with status $es."
}
trap 'errtrap $LINENO' ERR

cp no_perm yes_perm
echo "error"

When I run the script I get a output like this.
**********************
cp: cannot access no_perm
ERROR line 7: Command exited with status 2.
***********************

I would like to catch the error message " cp: cannot access no_perm " and display that with the print statement rather send in a mail at that place .
Is there any variable like $? which catches a error message . Much like sqlerrm variable in oracle .

I have done man ksh and did not find any .

I am doing this in script so that I don't have a option like
cp no_perm yes_perm 2>file
and then grep the content of file . Again for some reason i can't do call a script like test.ksh 2>/dev/null

Thanks
Ashok