Sreekanth1521
Programmer
#!/bin/bash
haf()
{
sshpass -p "$1" ssh -tt -o StrictHostKeyChecking=no "$2"@"$3" <<'SSH_EOF'
echo "request msha actions status" | /opt/tel/vs/ns/current/bin/ns_cli > txt1
tr -s " " < txt1 > txt2
cut -d " " -f 2 txt2 > txt3
var1=$(<txt3)
if [ "$var1" = "MASTER" ]
then
var2=1
elif [ "$var1" = "SLAVE" ]
then
var2=2
else
var2=3
fi
echo $var2 > txt4
rm txt1 txt2 txt3
logout
SSH_EOF
sshpass -p "$1" scp "$2"@"$3":~/txt4 .
var2=$(<txt4)
sshpass -p "$1" ssh -tt -o StrictHostKeyChecking=no "$2"@"$3" <<'SSH_EOF'
rm txt4
logout
SSH_EOF
rm txt4
return $var2
}
haf "$1" "$2" "$3"
FL1=$?
+++++++++++++++++++OUTPUT+++++++++++++++++++++++++
[highlight #8AE234]admin@tel:~$
/vs/ns/current/bin/ns_cli > txt1 request msha actions status" | /opt/tel
admin@tel:~$ tr -s " " < txt1 > txt2
admin@tel:~$ cut -d " " -f 2 txt2 > txt3
admin@tel:~$ var1=$(<txt3)
admin@tel:~$
admin@tel:~$ if [ "$var1" = "MASTER" ]
> then
> var2=1
> elif [ "$var1" = "SLAVE" ]
> then
> var2=2
> else
> var2=3
> fi
admin@tel:~$ echo $var2 > txt4
admin@tel:~$ rm txt1 txt2 txt3
admin@tel:~$ logout
Connection to 192.168.66.39 closed.
admin@tel:~$ rm txt4
admin@tel:~$ logout
Connection to 192.168.66.39 closed.[/highlight]
FL1=1
I do not want the colored text to be seen as part of my output.
Colored text is the script code itself.
My correct output is
FL1=1,
I just want this to be seen as my output.
I am running this script in Ubuntu 14.04.1
Thanks in advance
haf()
{
sshpass -p "$1" ssh -tt -o StrictHostKeyChecking=no "$2"@"$3" <<'SSH_EOF'
echo "request msha actions status" | /opt/tel/vs/ns/current/bin/ns_cli > txt1
tr -s " " < txt1 > txt2
cut -d " " -f 2 txt2 > txt3
var1=$(<txt3)
if [ "$var1" = "MASTER" ]
then
var2=1
elif [ "$var1" = "SLAVE" ]
then
var2=2
else
var2=3
fi
echo $var2 > txt4
rm txt1 txt2 txt3
logout
SSH_EOF
sshpass -p "$1" scp "$2"@"$3":~/txt4 .
var2=$(<txt4)
sshpass -p "$1" ssh -tt -o StrictHostKeyChecking=no "$2"@"$3" <<'SSH_EOF'
rm txt4
logout
SSH_EOF
rm txt4
return $var2
}
haf "$1" "$2" "$3"
FL1=$?
+++++++++++++++++++OUTPUT+++++++++++++++++++++++++
[highlight #8AE234]admin@tel:~$
/vs/ns/current/bin/ns_cli > txt1 request msha actions status" | /opt/tel
admin@tel:~$ tr -s " " < txt1 > txt2
admin@tel:~$ cut -d " " -f 2 txt2 > txt3
admin@tel:~$ var1=$(<txt3)
admin@tel:~$
admin@tel:~$ if [ "$var1" = "MASTER" ]
> then
> var2=1
> elif [ "$var1" = "SLAVE" ]
> then
> var2=2
> else
> var2=3
> fi
admin@tel:~$ echo $var2 > txt4
admin@tel:~$ rm txt1 txt2 txt3
admin@tel:~$ logout
Connection to 192.168.66.39 closed.
admin@tel:~$ rm txt4
admin@tel:~$ logout
Connection to 192.168.66.39 closed.[/highlight]
FL1=1
I do not want the colored text to be seen as part of my output.
Colored text is the script code itself.
My correct output is
FL1=1,
I just want this to be seen as my output.
I am running this script in Ubuntu 14.04.1
Thanks in advance