hello people
i am working on some kind of PBX and i have list of telephone numbers inside a file, i have to insert these numbers into the correct command and then telnet to a remote server and execute these commands.
i can read the telephone numbers and insert them into the command with no problem, but when i try to insert these commands into the send i face problem. here is the basic code
#!/bin/bash
read msisdn < input
string="ZZZZ:MSISDN=$msisdn;"
/usr/bin/expect <<delim
spawn telnet 172.20.64.133
expect "ENTER USERNAME <"
send "user\r"
expect "ENTER PASSWORD <"
send "password\r\r"
expect "<"
send "$string \r"
expect "<"
expect eof
delim
i can make external loop inside the Bash which read the input file and issue the command and then telnet and execute, but this will make the script connects and disconnects again for each line which cause high load on that server and hardwar problem.
i am wondering if there is an option inside the expect interperter which makes the send read directly from a file... somthing like this:
expect "<"
send "input-filename \r"
expect "<"
expect eof
i appreciate if anyone can help. thanks.