From: Why Tea on
$ wget --no-check-certificate --secure-protocol=SSLv3 --post-
data="userid=USERID&passws=PASSWD" -O /tmp/junk.log https://123.456.789.123
> /tmp/wget.log 2>&1

The wget command above works from a shell prompt, but when I tried the
following in tcl, it failed.

% set cmd "wget --no-check-certificate --secure-protocol=SSLv3 --post-
data=\"userid=USERID&passws=PASSWD\" -O /tmp/junk.log https://123.456.789.123
> /tmp/wget.log 2>&1"

% eval exec $cmd #### This fails!

Can anyone please help? Thanks.

/Why Tea
From: Robert Heller on
At Sun, 25 Apr 2010 02:27:08 -0700 (PDT) Why Tea <ytlim1(a)gmail.com> wrote:

>
> $ wget --no-check-certificate --secure-protocol=SSLv3 --post-
> data="userid=USERID&passws=PASSWD" -O /tmp/junk.log https://123.456.789.123
> > /tmp/wget.log 2>&1
>
> The wget command above works from a shell prompt, but when I tried the
> following in tcl, it failed.
>
> % set cmd "wget --no-check-certificate --secure-protocol=SSLv3 --post-
> data=\"userid=USERID&passws=PASSWD\" -O /tmp/junk.log https://123.456.789.123
> > /tmp/wget.log 2>&1"
>
> % eval exec $cmd #### This fails!
>
> Can anyone please help? Thanks.

exec takes a *list* not a *string*:

set cmd [list wget --no-check-certificate --secure-protocol=SSLv3 \
--post-data=\"userid=USERID&passws=PASSWD\" -O /tmp/junk.log \
https://123.456.789.123 >&/tmp/wget.log]
eval exec $cmd

>
> /Why Tea
>

--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller(a)deepsoft.com -- Contract Programming: C/C++, Tcl/Tk


From: Donal K. Fellows on
On 25/04/2010 13:28, Robert Heller wrote:
> exec takes a *list* not a *string*:
>
> set cmd [list wget --no-check-certificate --secure-protocol=SSLv3 \
> --post-data=\"userid=USERID&passws=PASSWD\" -O /tmp/junk.log \
> https://123.456.789.123 >&/tmp/wget.log]
> eval exec $cmd

And if it gets too complicated, you can always use the shell to help:

set cmd ...whatever...
exec /bin/sh -c $cmd

I've found this to be particularly useful when executing shell commands
supplied by users.

Donal.
From: Schelte Bron on
Why Tea wrote:
> $ wget --no-check-certificate --secure-protocol=SSLv3 --post-
> data="userid=USERID&passws=PASSWD" -O /tmp/junk.log
> https://123.456.789.123
>> /tmp/wget.log 2>&1
>
> The wget command above works from a shell prompt, but when I tried
> the following in tcl, it failed.
>
> % set cmd "wget --no-check-certificate --secure-protocol=SSLv3
> --post- data=\"userid=USERID&passws=PASSWD\" -O /tmp/junk.log
> https://123.456.789.123
>> /tmp/wget.log 2>&1"
>
> % eval exec $cmd #### This fails!
>
When translating a shell command line to a Tcl exec command you have
to consider the quoting rules of both. The quotes in the original
command are there to protect the & from the shell. Those quotes are
not actually passed to the command. In Tcl the & (in that location)
doesn't have any special meaning and doesn't have to be protected.

The easiest way to get the Tcl quoting of a command correct is to
use the list command.

Also, the 2>&1 sequence has special meaning to the shell. You need
to use the Tcl equivalent in your exec command. Robert Heller made
that change in his reply, but he didn't put a space between the >&
and the filename, which I think is needed.

Putting all this together, the following should work:
set cmd [list wget --no-check-certificate --secure-protocol=SSLv3 \
--post-data=userid=USERID&passws=PASSWD -O /tmp/junk.log \
https://123.456.789.123 >& /tmp/wget.log]
eval [linsert $cmd 0 exec]


Schelte.

From: Ralf Fassel on
* Robert Heller <heller(a)deepsoft.com>
| set cmd [list wget --no-check-certificate --secure-protocol=SSLv3 \
| --post-data=\"userid=USERID&passws=PASSWD\"

I don't think you need the " around the post-data here. Usually they
are used on the SHELL to quote spaces or other shell=special chars in
the arguments.
Simply
--post-data=userid=USERID&passws=PASSWD
should do the trick.

R'