×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

script is printing the code lines as part of the output

script is printing the code lines as part of the output

script is printing the code lines as part of the output

(OP)
#!/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"blushingtxt4 .
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+++++++++++++++++++++++++
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.

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

RE: script is printing the code lines as part of the output

Change the sshpass line to...

CODE

sshpass -p "$1" ssh -tt -o StrictHostKeyChecking=no "$2"@"$3" <<SSH_EOF > /dev/null 

...or...

CODE

sshpass -p "$1" ssh -tt -o StrictHostKeyChecking=no "$2"@"$3" <<SSH_EOF > /some/path/logfile.log 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close