shell script get ssh remote error -


i'm trying make remote mysqldump , afterwards download rsync working good, want log remote errors see in terminal output. mean errors mysqldump: got error: 1044: access denied user 'root'@'localhost' database 'information_schema' when using lock tables?

this important part of code:

mysql_cmd="mysqldump -u ${mysql_user} -p${mysql_pass} $db -r /root/mysql_${db}.sql" $ssh -p ${ssh_port} ${ssh_user}@${ssh_host} "${mysql_cmd}" >> "${logfile}" 

in research found solutions getting exit code , return values.

i hope can give me hint, in advance.

these error messages being written stderr. can redirect file using 2> or 2>> stdout > , >>. eg:

ssh ... 2>/tmp/logerrors 

note there no space between 2 , >. can merge stderr same file stdout replacing >> "${logfile}" with

ssh ... &>> "${logfile}" 

again, no space in &>, can written >&.


Comments