Sample Header Ad - 728x90

Expect script error- extra characters after close-quote

2 votes
2 answers
10227 views
Error while executing send if command, Not sure if I'm missing some tcl syntax. #!/usr/bin/expect -f # Get the list of hosts, one per line ##### set f [open "/tmp/host.txt"] set hosts [read $f] close $f # Iterate over the hosts foreach host $hosts { spawn ssh $host expect "password: " send "abcd@123\r" expect "$ " send "if [ df -Ph / | grep -vE '^Filesystem' | awk '{ print $5 " " $1 }' |cut -d'%' -f1 -ge 60 ] ;then echo "Hi Team- Please check root file system space on hostname " | mailx -s "Alert: Almost out of disk space on hostname" zoom@oracle.com ;fi\r" expect "$ " send "exit\r" expect eof } ---- *===Error===* [root@hzavks01~]# extra characters after close-quote while executing "send "if [ df -Ph / | grep -vE '^Filesystem' | awk '{ print $5 " " $1 }' |cut -d'%' -f1 -ge 60 ] ;then echo "Hi Team- Please check root file system..." ("foreach" body line 6) invoked from within "foreach host $hosts { spawn ssh $host expect "password: " send "abcd@123\r" expect "$ " send "if [ `df -Ph / | grep -vE '^Filesystem' | awk '{ print $5..." (file "./test.sh" line 10)
Asked by muku (51 rep)
Oct 30, 2018, 07:19 AM
Last activity: Jun 1, 2021, 10:53 PM