How can I capture the error returned from mysqldump and use it to take another action in a shell script? -
i'm using mysqldump in shell script dump several schemas production environment local one.
schemas = (one 2 three) read -p "enter username: " un read -s -p "enter password: " pw schema in "${schemas[@]}" : mysqldump -h serv -u $un --password=$p > /dev/null 2>&1 | mysql -uroot local done i'm redirecting out , error /dev/null prevent warnings , error messages, want able catch error , else based on output (e.g. access denied, not found).
how can capture error returned mysqldump , use take action in shell script?
for it's worth, $? variable seems 0 after mysqldump completes, if stderr access denied.
i did little more research , found answer here:
http://scratching.psybermonkey.net/2011/01/bash-how-to-check-exit-status-of-pipe.html
Comments
Post a Comment