hi, that the last line don't give a output is correct. the $@ works like a stack. if you fetch the first argument it will be removed and then the next one will be the first. if you want to access the argument more than one time you should use variables to thore them.
if you want to handle sms by the first word you can create for each word an own sms-service with the keyword like group = sms-service keyword = xyz exec = /.../xyz.sh ... group = sms-service keyword = abc exec = /.../abc.sh ... ... then %k is the first word %s is the second one and %r is the rest of the text. possibly it should be an option for you. to check if a sms comes in from a phone should be done in the script. for example by a file per vote with the sender numbers... the reason that you can see + instead of " " and %2B instead of "+" ... is the urlencoding... thats not a bug. here is a list: http://www.w3schools.com/tags/ref_urlencode.asp i would replace the characters in your script. an auto-generated receipt is also possible with kannel, i think. but i can't currently remeber how. br, thomas On Mon, Jun 07, 2010 at 04:09:21PM +0200, Martin J. wrote: | Hi, | | Yes, I understand most bash basics (and google what I don't understand) so I think everything more or less works, thanks: | | =============== | | mac$ which bash | /bin/bash | | =============== | | cat sms.sh | #!/bin/bash | | for var in $@; do | echo "$var" | tee -a incoming_sms_messages.txt | done | echo "-----------------------" | tee -a incoming_sms_messages.txt | | #echo Sms received, parameters are: $@ | | =============== | | | The last echo line doesn't work... I get output into my file: "incoming_sms_messages.txt", however it's strange that blank spaces are replaced by the "+"-sign... A bit annoying... I'm still thinking about recompiling everything with debug flags and set a breakpoint to see what is going on. I know C and C++, so I think there's a chance that I could fix the space -> "+" problem and then also learn a bit :-) | | | I'm also thinking about modifying my sms.sh script so that users for instance can vote (by sending an sms with keyword "vote" or something as first word) and the sms.sh script then automatically does something based on the contents of the sms (stores sms phone numbers, also it should be impossible to vote twice from the same phone number)... I think/hope I can do this myself - however, if you have any hints/clues, please let me know :-) | | And then I want to use lynx to auto-generate a receipt based on the vote ("thank you for your vote on xxxx")... That would be a nice assignment for me to do in the coming week :-) | | | | Regards, | Martin | | On Jun 7, 2010, at 3:34 PM, Thomas Sieh wrote: | | > | > hi, | > | > but when you run the script by typing | > /Users/path/to/the/script/sms.sh x y z | > n your console you get any output to | > the sms_messages.txt file? | > | > Another thing you can try is typing in your terminal: | > | > which bash | > | > possibly you have to correct the path to your bash in the first row. | > | > if you get a output into the file, then it should be a problem with | > kannel. | > | > i think you have make much changes in the sms.sh already. how it looks | > currently? | > | > br, | > thomas | > | > | > On Mon, Jun 07, 2010 at 02:01:27PM +0200, Martin J. wrote: | > | Wow, this was really timeconsuming challenge for me... | > | | > | Had to spend plenty of hours on googling for the exec line to see how other people did it and nothing worked, including write permissions etc. etc.... | > | | > | I even began to dig into the source code to try to see if there was/is a bug somewhere. I think the exec-code gets executed in ./gw/urltrans.c? | > | | > | I was thinking about recompiling everything with debug flags (-o0 -g, AFAIR) and then set a breakpoint just before running the exec-code (btw: what should I remember if I recompile with full debug flags, if anything?)... | > | | > | I finally succeeded by finding a piece of a configuration file that I stole from. Here's my new config-part regarding sms-service (and this solved my problem): | > | | > | ------------------------------------------ | > | group = sms-service | > | keyword = default | > | exec = ./sms.sh a=%a t=%t q=%q Q=%Q I=%I d=%d A=%A F=%F n=%n c=%c m=%m M=%M C=%C u=%u B=%B o=%o O=%O f=%f | > | # if max-messages = 0, then error "No reply sent, denied" | > | max-messages = 0 | > | #text = "Thank you! I appreciate your sms..." | > | concatenation = true | > | catch-all = yes | > | #white-list = "http://localhost/whitelist" | > | ------------------------------------------ | > | | > | After I have looked a bit in urltrans.c, I believe my problem was that I DIDN'T comment out the "text"-field and I guess that EITHER you have a text-reply ("Thank you!. ...") OR you have an exec-statement... Am I right? | > | | > | At least it works now using above config-file... I'm only a bit annoyed by the fact that in my incoming sms text file, all blank spaces are made into plus / "+"'es and I think a plus / "+" is made into "%2B" - this looks stupid in plain text when I "cat" the file.... | > | | > | Well, these are just minor things which I guess I can live with (search and replace plus'es with blank spaces or something)... | > | | > | | > | Any comments? | > | | > | And thanks again! Now somebody else perhaps can use my experience, if they get the same problem as me with the malfunctioning exec-statement :-) | > | | > | | > | | > | Regards, | > | Martin | > | | > | | > | On Jun 7, 2010, at 4:35 AM, Thomas Sieh wrote: | > | | > | > this should not be your problem. if you execute the script by hand and | > | > you don't get the corresponding output in the result file, there is a | > | > problem with the script. I think with the permission from the | > | > resultfile, if you have execute permissions to the script file. | > | > | > | > br, | > | > thomas
signature.asc
Description: Digital signature
