I have setup a xenserver (free) hosting a VM (Debian 7.5). On this xenserver I have attached a serial GSM modem. I have configured xen to run ser2net so I have a serial proxy available. This works perfectly local and remote (telnet). Now on the Debian VM I am running zenoss and I wish to use the paging functionality. I'm creating a bash script to simulate the telnet session and sending a message. This script is only working for 50%.
#!/usr/bin/expect set timeout 20 set number [lindex $argv 0] set message [lindex $argv 1] spawn telnet 10.10.0.52 3333 #wait? sleep 1 send AT+CMGS="$number"\r; expect ">" send "$message^Z"; interact #... Running the script:
administrator@debian:/home/zenoss$ ./sms.sh +32486000000 xxen spawn telnet 10.10.0.52 3333 Trying 10.10.0.52... Connected to 10.10.0.52. Escape character is '^]'. AT+CMGS="+32486000000" > xxen^Z I'm having problems sending the control character Ctrl+Z to initiate the send, it hangs. (note: the ^Z is the real character inserted with vi) Plus how should I go about multiple recipients? And how should I exit and disconnect.
EDIT: I tried
send "$message^Z";
to
send "$message"^Z;
but got this result:
administrator@debian:/home/zenoss$ ./sms.sh +32486000000 xxen spawn telnet 10.10.0.52 3333 Trying 10.10.0.52... Connected to 10.10.0.52. Escape character is '^]'. AT+CMGS="+32486000000" > extra characters after close-quote while executing "send "$message"^Z; interact #... " (file "./sms.sh" line 10) UPDATE:
#!/usr/bin/expect # - VAR set ctrlz \032 set xt \135 set timeout 15 set host [lindex $argv 0] set port [lindex $argv 1] set number [lindex $argv 2] set message [lindex $argv 3] # - CONNECT spawn telnet $host $port sleep 1 # - SEND send AT+CMGS="$number"\r; expect ">" send "$message$ctrlz"; expect "OK" # - END