Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am creating a script that backups a mysql db using the mysqldump utility. I am writing this script in the shell "sh". I would like to capture the output status of mysqldump in the script (i.e. if the mysqldump command failed or succeeded) so I can report if the script was successful or not.

  • Does mysqldump return an output status?
  • Can someone please give me instructions on how to do this?
share|improve this question
    
$ mysqldump .......... && echo "Yes" Replace the ... part with the parameters. If the command is successful it will show Yes otherwise nothing will be shown –  Manish Sinha Mar 21 '11 at 14:34
    
No exitcode/return value is mentioned in MySQL manual or its manual page. Note that sh is a symlink to dash in Ubuntu. –  Lekensteyn Mar 21 '11 at 15:21
add comment

1 Answer 1

up vote 1 down vote accepted

You could use bash exit codes.

Pseudocode

if $? == 0 then successful else ....
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.