curl-users
Re: curl with exec from a shell script
Date: Sat, 08 Feb 2003 01:13:55 -0600
Assuming you've got Tcl installed, and I'd be surprised if you haven't, this will
do the trick:
#!/usr/bin/tclsh
package require http
puts [::http::formatQuery [lindex $argv 0] [lindex $argv 1]]
Save the above to something like: /usr/local/bin/urlencode
In your script, do something like this for any POST variable with non-alphanumeric
values:
msgarg=`/usr/local/bin/urlencode MESSAGE
"$BBHOSTSVC-$BBCOLORLEVEL-$BBALPHAMSG&ORIGIN=bbserver"`
msgarg will be given the value "MESSAGE=cst1%2d5%2econn%2dred%2d%5...." so then
your curl command line becomes;
/usr/local/bin/curl -x 10.90.193.209:8080 -d $msgarg -d .... -d .....
http://smsgate.....
Also, I'm curious, why are you exec'ing curl? Does the script not do anything
else? Such as capture the return code from curl and report to someone (Big
Brother?) if it fails to send the pager message...
Ralph Mitchell
Harry Sufehmi wrote:
> Roth, Kevin P. said:
> > My bet is on the message content. Does BB have a way to URLencode the
> > "&MESSAGE=" parameter it sends? It's got a "%" sign embedded, which is perhaps
> > not a valid character for the receiving machine? It also has spaces embedded.
> > Usually spaces should turn into "%20"...
>
> alright.... hmm, if there's a small utility that does it, then I can call it
> from within BB's script, so it will convert the string properly before given to
> curl...
> let's see if I can find anything that will do this.
>
> > If you still can't find the problem, please also post this same section from
> > the version that worked (that you ran manually). The one that's only 300-some
> > bytes long. It would be interesting to see what
> > the differences are.
>
> Indeed... however I'm at home at the moment, and everything is at my office.
> I'll post it first thing in Monday morning.
>
> cheers,
> Harry
>
> > -----Original Message-----
> > From: Harry Sufehmi [mailto:milis-ktr_at_harrysufehmi.com]
> > Sent: Friday, February 07, 2003 1:20 PM
> >
> > However, the trace file looks okay to me.
> > Then again, I'm no expert on curl.
> >
> > Any idea why it doesn't work?
> >
> > --------------------
> > == Info: About to connect() to 10.90.193.209:8080
> > == Info: Connected to 10.90.193.209 (10.90.193.209) port 8080
> > => Send header, 314 bytes (0x13a)
> > 0000: POST http://smsgate.truesenses.com/cgi-bin/smsgateway.cgi HTTP/1 0040:
> > .1
> > => Send data, 409 bytes (0x199)
> > 0000: ACCOUNT=myaccount&PASSWORD=mypassword&NUMBER=mymobilephone&MESSAGE=cs
> > 0040: t1-5.conn-red-[6931010] cst1-5.conn red Fri Feb 7 16:04:45 GMT 0080:
> > 2003 ERROR: Can't connect to 10.110.209.15 .PING 10.110.209.15 00c0:
> > (10.110.209.15): 56 data bytes..--- 10.110.209.15 ping statistic 0100: s ---.1
> > packets transmitted, 0 packets received, 100% packet los 0140: s..Please see:
> > http://bb-server/bb/html/cst1-5.conn.html.&ORIGIN 0180:
> > =bbserver&CMD=SENDMESSAGE
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
Received on 2003-02-08