Hi!
I have a script, which calls another script on a remote machine using ssh.
I need to check if the remote running script is succesful. If it is succesful I need to continue the for loop (run it on another machine) or break the loop.
Please let me know if anyone has an idea on checking the status of the script on remote machine .
My script is as below.
./sshlogin.exp $passw $host $username statement would trigger the second script on a remote machine.
#!/usr/bin/sh
##Take input from the user
c=d=e=0
while [ "$host_name" != done ]
do
echo "Please enter the host_name"
read host_name
if [ "$host_name" = done ] ; then break; fi
store_hostname[$c]=$host_name
#Check if hostname is correct
validHost=`host $host_name | grep 'not found'`
if [ "$validHost" != "" ] ; then
echo "Checking Host" 'Host cannot be resolved. Please check your hostname'
exit 1
fi
c=$(( c + 1 ))
echo "Please enter the username"
read username
store_username[$d]=$username
d=$(( d + 1 ))
echo "Please enter the password"
read -s password
store_password[$e]=$password
e=$(( e + 1 ))
done
echo ${store_hostname[0]}
len=${#store_hostname
[*]}
echo $len
for (( i=0; $i < $len; i++ ))
do
host=`echo ${store_hostname[$i]}`
passw=`echo ${store_password[$i]}`
username=`echo ${store_username[$i]}`
ssh -q host@username date
./scplogin.exp $passw $host $username
./sshlogin.exp $passw $host $username
if [ "$?" = 1 ] ; then break; fi
done