curl-users
Re: command line completely broken re. arguments
Date: Fri, 06 Oct 2006 18:26:36 +0200
On Fri, 6 Oct 2006 12:24:06 +0200 (CEST) Daniel Stenberg wrote:
> That parsing is done and handled by your shell and has nothing to do
> with curl. Fix your shell and curl will work as documented.
that's what i thought all along, and it's correct, and i'm wrong. guess
i'll have to apologize for the subject line.
the shells on freebsd are perfectly ok, btw.
i did more testing. my script seems to be doing what it's supposed to
do given debug outputs, but it doesn't work. it is a rather simple
shell/awk script-combo collecting pieces from a spamcop message in order
to automatically submit the web form one gets for verifying the spam
report/analyses. if i use "screen" (terminal emulator) to mark and then
paste the scripts output to either bash or sh, the generated lines and,
of course, curl, do work fine, but they don't when executed by the shell
script.
i know this is not a curl issue, but it would be nice if someone could
glance through the script and maybe point out the error. you would feed
it the raw (HTML, not text rendered) verification message from spamcop
on stdin. my version makes curl complain about "-0000" not being a valid
option. the specific argument is "-F 'date=3 Oct 2006 18:35:23 -0000'",
which made me think it was curls fault.
again, apologies and regards, clemens
--- start of script ---
#!/bin/sh
# $Header: /root/bin/RCS/spamcop-verify.sh,v 1.6.2.1 2006/10/06 15:26:49 root Exp root $
#
# use gnu-awk
AWK="gawk --re-interval"
curlargs="-v --trace-ascii -"
curlargs="${curlargs} $(${AWK} '
BEGIN {
IGNORECASE=1
now=0
cont=0
start=0
contnam=""
contval=""
collect=""
}
!now && /^[[:blank:]]+enctype="multipart.form-data" name="sendreport"/ {
now=1
}
now && /^<\/form><\/div>/ {
now=0
}
# name/value are separated by blanks
now && /^<input type="hidden" name=.+value=.+$/ {
start = match($0, /name="([^"]+)"[[:space:]]+value="([^"]+)"/, namval)
if (start != 0) {
collect = collect " -F \x27" namval[1] "=" namval[2] "\x27"
}
}
# name/value may be separated by blanks/newlines
now && /^<input type="hidden" name="info[^"]+"[[:blank:]]*$/I {
cont = 1
start = match($0, /name="([^"]+)"/, namval)
if (start != 0) {
contnam = namval[1]
}
}
# continue w/ line immediately following to find the value
now && cont && /^[[:blank:]]*value=/ {
cont = 0
start = match($0, /value="([^"]+)"/, namval)
if (start != 0) {
collect = collect " -F \x27" contnam "=" namval[1] "\x27"
}
}
now && /^<input type="checkbox" name=.+checked>.*$/ {
start = match($0, /name="([^"]+)"/, namval)
if (start != 0) {
collect = collect " -F \x27" namval[1] "=on\x27"
}
}
#<input type="submit" value="Send Spam Report(s) Now">
#<input type="submit" name="preview" value="Preview Reports">
#<input type="submit" name="cancel" value="Cancel">
# submit buttons
now && /^<input type="submit"[[:blank:]]+value=.+$/ {
start = match($0, /value="([^"]+)"/, namval)
if (start != 0) {
collect = collect " -F \x27" "submit=" namval[1] "\x27"
}
}
END {
printf("%s", collect)
} ')"
curlargs="${curlargs} -s -A 'Lynx/2.8.5 (Compatible; ELinks)'"
#curlargs="${curlargs} http://www.spamcop.net/sc"
curlargs="${curlargs} http://localhost:8008/sc"
echo ${curlargs}
#curl ${curlargs} | elinks -dump 1 -force-html -no-references -no-connect 1
curl ${curlargs}
--- end of script ---
the output looks like this:
$ spamcop-verify.sh < /home/www/webfs/spamcop-form-sc.html
-v --trace-ascii - -F 'action=flexsend' -F 'spamid=1088908651' -F 'crc=2824e2b54f48ccca5369ca9cb43e53e1' -F 'date=3 Oct 2006 18:35:23 -0000' -F 'source=85.96.226.187' -F 'reports=abuse@ttnet.net.tr:source:85.96.226.187|postmaster#ttnet.net.tr@devnull.spamcop.net:source:85.96.226.187|spamcop@imaphost.com:i-source:85.96.226.187' -F 'send1=on' -F 'type1=source' -F 'master1=abuse@ttnet.net.tr' -F 'info1=85.96.226.187' -F 'send2=on' -F 'type2=source' -F 'master2=postmaster#ttnet.net.tr@devnull.spamcop.net' -F 'info2=85.96.226.187' -F 'send3=on' -F 'type3=i-source' -F 'master3=spamcop@imaphost.com' -F 'info3=85.96.226.187' -F 'goodrelay=mail.webmonster.de' -F 'max=3' -F 'submit=Send Spam Report(s) Now' -s -A 'Lynx/2.8.5 (Compatible; ELinks)' http://localhost:8008/sc
curl: option -0000': is unknown
curl: try 'curl --help' or 'curl --manual' for more information
i had "echo ${curlargs} | cat -v", even "hexdump" and "sed -n l" to
check for control characters in there, but nothing :-(
Received on 2006-10-06