I call a EXPECT script from my perl script with machine IP and a FIle. The script logins to the machine and exports the value. I have close to 10 machines and I have created 10 files and pass the corresponding files in command line.
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...
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...
Code:
#!/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
Comment