Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've set up a Xenserver hosting a Debian VM with Zenoss Core 4.2.4. The Xenserver has a Siemens T35 GSM Modem attached to its serial port COM1. I used ser2net + some Xenserver configuration to get it working. (COM1 binding, SELinux, ...) I created a shell script that can easily send SMS messages.

I created a trigger + notification and everything works perfectly EXCEPT that the message is empty!!!

Here is the script:

#!/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]
# - LOG
log_file -a sms.log;
send_log "$host $port $number:$message"
# - CONNECT
spawn telnet $host $port
sleep 1
# - SEND
send AT+CMGF=1\r;
expect "OK"
send AT+CMGS="$number"\r;
expect ">"
send "$message$ctrlz";
expect "OK"
# - END

And here is the Zenoss Page Command:

$ZENHOME/bin/sms.sh 10.10.0.52 3333 $RECIPIENT

This works in Linux as follows:

./sms.sh 10.10.0.52 3333 +32486000000 message

I just can't get the message from Zenoss in the SMS message.... I need to complete this last step to get it fully working!

If I try sending a test message from Zenoss, it also arrives but with no text...

Thank you for your time!

share|improve this question
    
Extra, updated the script to log what it's getting for parameters but this doesn't work when being called from Zenoss... I'm new to bash scripting btw. –  grmbl Jun 4 at 6:45

3 Answers 3

The problem appears to be that from my understanding Zenoss sends the actual message to the scripts STDIN input, but your script expects it as a command line parameter. You have to modify your expect script in a way that it will read the message from STDIN instead of $argv 3. After that, your test script should work like this:

echo "Message" | ./sms.sh 10.10.0.52 3333 +32486000000 

I don't really know expect, so I can't help with the actual script.

share|improve this answer
    
I know, I just figured this out myself but I can't answer my own question. Need +5 rep :( –  grmbl Jun 4 at 9:02
    
lol, now I can't upvote yet... grrrr :) –  grmbl Jun 4 at 9:07
    
@grmbl Now you can. –  jscott Jun 4 at 11:08
up vote 2 down vote accepted

It's working,

I looked in the /usr/local/zenoss/Products/ZenUtils/Utils.py file to find that Zenoss sends the message text to stdin so I only needed to read stdin in the expect script to get the message.

Here is the new working script: (note that I left out host & port parameters)

#!/usr/bin/expect
# - VAR
set ctrlz \032
set xt \135
set timeout 15
set number [lindex $argv 0]
set message [gets stdin]
# - LOG
log_file -a sms.log;
send_log "$number:$message"
# - CONNECT
spawn telnet 10.10.0.52 3333
sleep 1
# - SEND
send AT+CMGF=1\r;
expect "OK"
send AT+CMGS="$number"\r;
expect ">"
send "$message$ctrlz";
expect "OK"
# - END

Hope this will help anyone!

share|improve this answer

expect ">"? Is that some kind of copy-paste error or should that actually be expect ">"?

share|improve this answer
    
:) fixed the html character –  grmbl Jun 4 at 6:42
    
Can you upvote my question, I need +5 rep to answer my own question and I have it in clipboard. :) –  grmbl Jun 4 at 8:55
    
Upvoted. Have a nice day! :) –  Janne Pikkarainen Jun 4 at 8:56
    
Thank you and have a nice day too! :) –  grmbl Jun 4 at 9:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.