Hello,
I am trying to get a custom message sent from Hobbit via sms.
All I want is the hostname with a short message sent after it.
So far I have
#!/bin/bash
echo "${BBHOSTNAME:0:160} cpu is red" | gnokii --sendsms 1234567890
I am using gnokii as the gate way.
I think my variable is what is causing the problem, can someone see where I have gorn wrong?
Jarrod Hodder
Paradigm Management Group
110 Livingston Avenue
Kambah, ACT 2902
1300 735 370
Jarrod at pmg.net.au
try: echo "${BBHOSTNAME}:0:160 cpu is red" | gnokii --sendsms 1234567890
From: Jarrod Hodder [mailto:Jarrod.Hodder at pmg.net.au] Sent: Thursday, March 19, 2009 12:18 AM To: hobbit at hswn.dk Subject: [hobbit] SMS Alerts
Hello,
I am trying to get a custom message sent from Hobbit via sms. All I want is the hostname with a short message sent after it.
So far I have
#!/bin/bash echo "${BBHOSTNAME:0:160} cpu is red" | gnokii --sendsms 1234567890
I am using gnokii as the gate way. I think my variable is what is causing the problem, can someone see where I have gorn wrong?
Jarrod Hodder
Paradigm Management Group 110 Livingston Avenue Kambah, ACT 2902
1300 735 370
Jarrod at pmg.net.au
Your suggestion indicates you do not understand what he was trying to do :) He was trying to cut the hostname short, by having a maximum of 160 characters. http://tldp.org/LDP/abs/html/string-manipulation.html (see the section Substring Extraction)
It is a feature for BASH shells, but maybe some modern Bourne shells have it as well (I know I used it on some modern HP/UX with their standard /bin/sh) So putting the :0:160 outside the brackets would not yield the desired result. On the other hand, hostnames rarely go that long, so cutting it short seems quite useless.
I am not familiar with gnokii, but does it actually take a message from stdin? Or does it normally use a 'gnokii --sendsms <number> <message>' format? Otherwise, I don't see anything wrong with your syntax.
Van: Galen Johnson [mailto:Galen.Johnson at sas.com] Verzonden: donderdag 19 maart 2009 7:53 Aan: hobbit at hswn.dk Onderwerp: [hobbit] RE: SMS Alerts
try:
echo "${BBHOSTNAME}:0:160 cpu is red" | gnokii --sendsms 1234567890
From: Jarrod Hodder [mailto:Jarrod.Hodder at pmg.net.au] Sent: Thursday, March 19, 2009 12:18 AM To: hobbit at hswn.dk Subject: [hobbit] SMS Alerts
Hello,
I am trying to get a custom message sent from Hobbit via sms.
All I want is the hostname with a short message sent after it.
So far I have
#!/bin/bash
echo "${BBHOSTNAME:0:160} cpu is red" | gnokii --sendsms 1234567890
I am using gnokii as the gate way.
I think my variable is what is causing the problem, can someone see where I have gorn wrong?
Jarrod Hodder
Paradigm Management Group
110 Livingston Avenue
Kambah, ACT 2902
1300 735 370
Jarrod at pmg.net.au
You are correct. I never program bash scripts. I have always used bourne only to ensure the script will run on any server I put it on without going through hoops (just how I was raised). Most modern shells have a Bourne-shell mode when called as /bin/sh. Many modern linux distros have sh either hardlinked or symlinked to bash. Didn't realize you could do string manipulation like that (I usually just pipe to cut)
=G=
From: Kip, D. - GDI/SNB [mailto:d.kip at gdi.minjus.nl] Sent: Thursday, March 19, 2009 6:43 AM To: hobbit at hswn.dk Subject: RE: [hobbit] RE: SMS Alerts
Your suggestion indicates you do not understand what he was trying to do :) He was trying to cut the hostname short, by having a maximum of 160 characters. http://tldp.org/LDP/abs/html/string-manipulation.html (see the section Substring Extraction)
It is a feature for BASH shells, but maybe some modern Bourne shells have it as well (I know I used it on some modern HP/UX with their standard /bin/sh) So putting the :0:160 outside the brackets would not yield the desired result. On the other hand, hostnames rarely go that long, so cutting it short seems quite useless.
I am not familiar with gnokii, but does it actually take a message from stdin? Or does it normally use a 'gnokii --sendsms <number> <message>' format? Otherwise, I don't see anything wrong with your syntax.
Van: Galen Johnson [mailto:Galen.Johnson at sas.com] Verzonden: donderdag 19 maart 2009 7:53 Aan: hobbit at hswn.dk Onderwerp: [hobbit] RE: SMS Alerts try: echo "${BBHOSTNAME}:0:160 cpu is red" | gnokii --sendsms 1234567890
From: Jarrod Hodder [mailto:Jarrod.Hodder at pmg.net.au] Sent: Thursday, March 19, 2009 12:18 AM To: hobbit at hswn.dk Subject: [hobbit] SMS Alerts
Hello,
I am trying to get a custom message sent from Hobbit via sms. All I want is the hostname with a short message sent after it.
So far I have
#!/bin/bash echo "${BBHOSTNAME:0:160} cpu is red" | gnokii --sendsms 1234567890
I am using gnokii as the gate way. I think my variable is what is causing the problem, can someone see where I have gorn wrong?
Jarrod Hodder
Paradigm Management Group 110 Livingston Avenue Kambah, ACT 2902
1300 735 370
Jarrod at pmg.net.au
Here's what I do -
cut the message down to 150 characters (allows spatch room for
a security code on echelon pages
TEXT=echo "${BBALPHAMSG}" | grep "&red"
TEXTP=echo "!BB ! - ${BBHOSTSVC} [${ACKCODE}] $FIXED- ${TEXT}" | paste -sd" " | cut -c 1-150
The grep for &red pulls out only the lines in alphamsg that have a 'red' indicator - for tests like procs or oratab that have multiple lines. The "!BB!" is a holdover; I don't remember why we did it. "FIXED" will be null ("") or "FIXED" depending on the $RECOVERED value - and the entire message gets cut to the first 150 characters (our current paging package puts in it's own acknowledgement code at the start of the message). The paste -sd" " converts the newlines into spaces before the cut process.
HTH
Tom
From: Jarrod Hodder [mailto:Jarrod.Hodder at pmg.net.au] Sent: Thursday, March 19, 2009 12:18 AM To: hobbit at hswn.dk Subject: [hobbit] SMS Alerts
Hello,
I am trying to get a custom message sent from Hobbit via sms. All I want is the hostname with a short message sent after it.
So far I have
#!/bin/bash echo "${BBHOSTNAME:0:160} cpu is red" | gnokii --sendsms 1234567890
I am using gnokii as the gate way. I think my variable is what is causing the problem, can someone see where I have gorn wrong?
Jarrod Hodder
Paradigm Management Group 110 Livingston Avenue Kambah, ACT 2902
1300 735 370
Jarrod at pmg.net.au
CONFIDENTIALITY NOTICE: This email and any attachments are for the exclusive and confidential use of the intended recipient. If you are not the intended recipient, please do not read, distribute or take action in reliance upon this message. If you have received this in error, please notify us immediately by return email and promptly delete this message and its attachments from your computer system. We do not waive attorney-client or work product privilege by the transmission of this message.
Jarod,
I don't see where your problem is:
This is my alert script rule HOST=home.nouwen.name SERVICE=* SCRIPT /usr/local/bin/sendsmshobbit.sh 3123456789 REPEAT=1h TIME=*:1000:2200 COLOR=red FORMAT=sms
The script contains:
#!/bin/sh #set -vx #debug on:: #echo "/usr/local/bin/sendsms $RCPT $BBALPHAMSG $ACKCODE" >> /tmp/smsd.log /usr/local/bin/sendsms $RCPT "$BBALPHAMSG $ACKCODE"
/usr/local/bin/sendsms is the binary from smsd.
The message is then formatted as:
(see the debug rule)
/usr/local/bin/sendsms 342384723 *home.nouwen.name:conn red [512857 512857*
this is allways smaller then 160 chars, so......
Gé
Jarrod Hodder wrote:
Hello,
I am trying to get a custom message sent from Hobbit via sms.
All I want is the hostname with a short message sent after it.
So far I have
#!/bin/bash
echo "${BBHOSTNAME:0:160} cpu is red" | gnokii --sendsms 1234567890
I am using gnokii as the gate way.
I think my variable is what is causing the problem, can someone see where I have gorn wrong?
*Jarrod Hodder*
*_ _*
Paradigm Management Group
110 Livingston Avenue
Kambah, ACT 2902
1300 735 370
Jarrod at pmg.net.au
participants (5)
-
d.kip@gdi.minjus.nl
-
Galen.Johnson@sas.com
-
ge.janssen@gmail.com
-
Jarrod.Hodder@pmg.net.au
-
KauffmanT@nibco.com