Bash Script Help!

A basic one here.
I have a programme that send sms's to a list of hard-coded numbers, all it expects is the message passed to it in form of:
/usr/local/sbin/sms.sh 'this is message'

However i am trying to write a script that will automate sending sms's notifying when mysql replication fails. Now all that is down and the part keeping me back is following....

I cannot get any script to pass a message that contains a variable to the sms script.

ie...

Tried this..
#!/usr/local/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin


srvname=`hostname`
smsscript='/usr/local/sbin/sms.sh'
error="'Replication is not configured or you do not have the required access to MySQL on $srvname'"
#echo $error
#echo $smsscript
echo $smsscript $error

#srvname=`hostname`
# /usr/local/sbin/sms.sh $error
exec $smsscript $error


As you can see ive tried many ways with no hope, i can only execute sms.sh with a static entry... ie
/usr/local/sbin/sms.sh 'Replication is not configured or you do not have the required access to MySQL on $srvname'
will send sms but the variable $srvname stays that!

Tried
/usr/local/sbin/sms.sh "'Replication is not configured or you do not have the required access to MySQL on $srvname'"

Which will replace $srvname with reall value , but results in no sms.


Help Gururs!!
 
Code:
" <- variables between these will be updated
' <- variables between these will not be updated

example:
Code:
$ echo "$PATH"
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$ echo '$PATH'
$PATH
 
Thanks For Info!

However that meens that in theory this is supposed to work but doesn't...

/usr/local/sbin/sms.sh "'Replication is not configured or you do not have the required access to MySQL on $srvname'"

I first wrap it with the ' because the sms.sh expects that, then wrap that with " to ensure variable gets updates.

Input?
 
Maybe
Code:
smsscript=/usr/local/sbin/sms.sh
error="Replication is not configured or you do not have the required access to MySQL on $srvname"

$smsscript \'$error\'
 
Back
Top