Reputation: 1751
I am new to Expect scripts. I have Expect script written in a bash script. The script returns me the statistics I require but along with a lot of other stuff from the terminal. "Is there any way I can get precisely the output of the command only?" I have spent a day searching various forums but didn't had any luck. Any sort of help will be appreciated.
Stats = $(expect -c "
spawn ssh $Username@$Host
expect \"password:\"
send \"$Password\r\"
expect \"\\\\$\"
send \"ps -A | grep java\r\"
expect -re \"$USER.*\"
send \"logout\"
")
echo $Stats > someFile.txt
Upvotes: 2
Views: 597
Reputation: 97948
You can turn of logging except for the command output:
expect -c "
log_user 0
spawn ssh $Username@$Host
expect \"password:\"
send \"$Password\r\"
expect \"\\\\$\"
log_user 1
send \"ps -A | grep java\r\"
expect -re \"$USER.*\"
send \"logout\"
"
Upvotes: 1