the following expect script target is to print the hostname name from linux/solaris machine and according to hostname results expect script will run linux.ksh or solaris.ksh script
expect_sun_script=`cat << EOF
set timeout -1
spawn telnet 0 $IP_ADDRESS
expect login: {send $LOGIN\r}
expect Password: {send "PASS\r"}
expect -re {#|>} {send "/bin/hostname\r"}
so - after I get the hostname name I need to run linux.ksh for hostname - machine1
or if I get hostname - machine2 then I need to run the script - solaris.ksh
but how expect can run the script according to the hostname name?
according to my example below:
expect actually wait for machine1 - but it could be machine2 so its stuck ....
my target is to run linux.ksh or solaris.ksh according to the relevant hostname
please advice ?
expect "machine1" { send "/var/tmp/linux.ksh\r " }
expect "machine2" { send "/var/tmp/solaris.ksh\r" }
.
.
.
.
.
.