I am trying to SSH a client after i configured RSA connection. I would like to verify if SSH connection is successful, if yes then would like to source it first by calling a function then execute the command on client.Below is the script i am trying to execute on server,
function set_env() {
if [ -f /usr/pw/server/bin/setup_env.sh ]; then
source /usr/pw/server/bin/setup_env.sh
elif [ -f /etc/mcell/setup_env.sh ]; then
source /etc/mcell/setup_env.sh
else
echo "setup_env.sh not found, exiting"
exit 1
fi
}
i="application_was"
if ssh clientname
then
set_env
mcstat -q -n $i | grep "Running"
else
echo "Sorry"
fi
I am able to SSH to the client but set_env function is not executed on the client upon login. How do i make sure it happens ? how to catch the error if it doesn't ?
expect(1)to script interactive programs.