I could like to do this with a sinle file. I will create a file as below
MAchine1
EXPORT VAR1=
EXPORT VER2=
EXPORT VAR3=
MAchine1
Machine2
EXPORT VAR1=
EXPORT VER2=
EXPORT VAR3=
MAchine2
Now I need to take the Info present between machine1 and store it an array and then pass it to expect script. I can take the values in an array but not sure how to use the values stored in array and use it in EXPECT script.. Any pointers will be helpful...
Expand|Select|Wrap|Line Numbers
- #!/bin/ksh
- set klug { ${1+"$@"}
- shift
- shift
- exec /usr/bin/expect -f $0 ${1+"$@"}
- }
- set ip [lindex $argv 0 ]
- set file [lindex $argv 1]
- spawn ssh -o stricthostkeychecking=no root@$ip
- expect -re "Password"
- send "password\r"
- set fp [open $file ]
- while {-1 != [gets $fp line]} {
- send "$line\r"
- }
- interact