-2

This is the portion of a bash script that is called from another script and by virtue of it's design uses this else statement.

How do I successfully add an echo or some other means to tell where it is not working? The script continues on to the next portion of the script but I have not idea how to tell if these commands ran.

I tried to add echo ""; after each command and it gives a 'not clean' error I assume b/c of the output.

else

  mysql -u dbrootadmin --password=`cat /root/.mysql_pw` << '_EOF_' >"$TMPFILE" 2>&1
FLUSH TABLES WITH READ LOCK;
FLUSH LOGS;
system  /usr/local/bin/CreateRootSnapshot
UNLOCK TABLES;
_EOF_
Rocco The Taco
  • 3,695
  • 13
  • 46
  • 79
  • 1
    Everything after the line with `<< '_EOF_'` up to the line with `_EOF_` is fed to mysql, not processed by bash at all, so it would make sense that `echo`s in that area would have unexpected effects. – Charles Duffy Jun 23 '17 at 19:42

1 Answers1

1

You could turn on debugging and exiting if there is an error in bash. In the man-page under the "SHELL BUILTIN COMMANDS" section.

set -x makes the shell expand what it's doing and echo it out.

set -e makes the shell exit if there is an error.

Timothy Brown
  • 2,220
  • 18
  • 22