Hi all,
Im new at scripting and i need to run a few commands at work every hours so i decide to make a script but on 1 of the steps i have a the follwoing problem:
The command i do is this:
#!/bin/bash
ssh root@asdasd001 'mysql -h A-db-1 -uroot -password --execute "show slave status"'
and when i run the script the error it appear is:
bash-3.00# ./test
sh: mysql: not found
Thanks in advance.
Br
You need to set the environment with something like this, to get $PATH and other local supporting variables the shell and mysql app need:
ssh root@asdasd001 '. ./.profile ; mysql -h A-db-1 -uroot -password --execute "show slave status"'
(Does this really require the power of root? Using a sledge to set tacks eventually gives hurt fingers.)
Thanks for the fast response but the problme persistss
Just for clearing out of the script i just do:
ssh asasasa
and on the asasasa machine i just run the command
mysql -h A-db-1 -uroot -pass --execute "show slave status"
#!/bin/bash
ssh asasasa '../.profile ; mysql -h A-db-1 -uroot -pass --execute "show slave status"'
bash-3.00# ./test
sh: ../.profile: not found
sh: mysql: not found
Neo
October 28, 2010, 11:01am
4
Just use the full PATH of mysql. That is what most of us do. When running commands from scripts, as a common best practice, always use the full path.