I have an expect script which provides the IP address:
#!/bin/expect -fset nodename [lindex $argv 0]spawn virsh console $nodenameexpect "Escape character is"send "\n"expect "localhost login: " { send "root\n" expect "Password: " send "cloud123\n"}expect "~]#" { send "\n" send "ifconfig | grep 192.168.1. | awk \'{print \$2}\'" send "\n" expect '(\d+\.\d+\.\d+\.\d+)' send "logout"}
I want the script to return this IP address. I am calling this expect script from a shell script as below
#!/bin/baship=$(expect GetIP.exp nodetwo)echo $ip
How can I make my expect script return output to the shell script?