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 hostsforeach host $hosts {spawn ssh $hostexpect "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 $hostexpect "password: "send "abcd@123\r"expect "$ "send "if [ `df -Ph / | grep -vE '^Filesystem' | awk '{ print $5..." (file "./test.sh" line 10)