Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cURL anyone?

32 views
Skip to first unread message

Louis Windsor

unread,
Sep 27, 2003, 8:56:21 PM9/27/03
to
I eventually got down to retry cURL and what follows is my tale of woe!

First I had this ENGINE_by_id problem.  So I downloaded the latest OpenSSL
package.  Then I found that if your link has an "&" in it DOS treats what comes
after each "&" as a separate command.  So at the Command Prompt I
enclosed the link in double quotes.

Yeh! At the Command Prompt (DOS) I got "curl" to work.

I now tried this within the EXECUTE "DOS /c 'curl ... "https..."'".

Of course I had to define various parts of the command as three levels of
quotes aren't available.  Now I am stuck!!!!

If I put double quotes around the address, cURL fails as it can't recognise
'protocol ["https].  It is obviously taking the double quote as part of the
https.

If I remove the double quotes DOS interprets the address as multiple
DOS commands.

Has anyone used cURL from within a UniVerse BASIC program with
multiple "&" in the address link with PE on Win32(XP)?

Oh yes as a final woe UniVerse won't load with the new libeay32.dll.  I
THINK I may get away with a different versions of libeay32 in "bin" and
in /IBM/UV.  That way UniVerse will load with the old dll in "bin" and
my EXECUTE will use the new one outside of "bin" but it is not worth
trying till I can solve the ["https] protocol thingy.

I'm only trying cURL as I can't get beyond security-contexts and
certificates that createSecureRequest requires.

For months(6) I read a https address with an ordinary createRequest
but when I moved to my new system it stopped working and now
requires "secure" logic?

Louis

Doug Dumitru

unread,
Sep 27, 2003, 9:20:34 PM9/27/03
to
A couple of thoughts on your situation:

1. Are you running curl "straight" or under cygwin. If under
cygwin, there are a whole bunch of things that don't work quite as
expected. Try writing a cygwin shell script on the fly and the
executing this from UV. This will likely get around your quoting
issues.

2. If somehow you have curl native, then try writing a .bat file
and then executing that. This may still get you around the quoting
fun.

3. Switch to Linux. This and a whole bunch of other stuff is just
better there ;)


--------------------------------------------------------------------
Doug Dumitru 800-470-2756 (610-237-2000)
EasyCo LLC do...@easyco.com http://easyco.com
--------------------------------------------------------------------
D3, U2, jBase Virtual Servers. Off-site backup over the internet.
Develop/test/deploy from $20/mo. Fast, secure, cheaper than tape.
http://mirroredservers.com http://mirroredbackup.com

Louis Windsor

unread,
Sep 28, 2003, 1:02:48 AM9/28/03
to
Hi Doug,

I'm running curl in an EXECUTE \DOS /c 'curl -k "https:......"'\

I don't know if this answers your questions 1 & 2.

I might give a .bat file a go. I assume that still has to be
EXECUTE \DOS /c 'curl ... ... ...'\

I have actually got things to work by putting a space after the
double quote and removing the matching double quote at the
end of the link. curl throws up an error [Couldn't resolve
host '"'] but it works!!!! As in :-
EXECUTE \DOS /c 'curl -k "spacehttps:......"'\
I can live with that if I can't find a more aesthetically
pleasing solution.

Louis

"Doug Dumitru" <do...@easyco.com> wrote in message
news:0mdcnvg0qfnlel3up...@4ax.com...
: A couple of thoughts on your situation:

Glen

unread,
Sep 28, 2003, 2:03:40 PM9/28/03
to
On Sun, 28 Sep 2003 08:56:21 +0800, "Louis Windsor"
<lou...@tpg.com.au> wrote:

You need to URL-encode the URL before using it on a command line.

FOR X = 1 TO LEN(OUTBUF)+1
HEX=''
BEGIN CASE
CASE OUTBUF[X,1] = "&"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "+"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = '"'; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "'"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "%"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "@"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "`"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "\"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "#"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "["; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "]"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "-"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = ":"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = ";"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "~"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "/"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "!"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "{"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "}"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "|"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "*"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "^"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "$"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = ">"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "<"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "."; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = ","; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "="; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
CASE OUTBUF[X,1] = "?"; HEX="%":DTX(SEQ(OUTBUF[X,1]))"R#2"
END CASE
IF HEX = "" THEN OUTBUF2 = OUTBUF2:OUTBUF[X,1]
IF HEX # "" THEN OUTBUF2 = OUTBUF2:HEX
NEXT X

Glen

http://picksource.com/phpnuke/

Patrick Payne

unread,
Sep 28, 2003, 4:36:40 PM9/28/03
to
I really recommend you create a curl.rtne to wrap you calls in. I
would then have this routine create a .bat file (like Doug stated) to
do the actual work. This does a few things.

#1: Easier to debug -> ie. create a debug option that does not delete
the .bat file after execution. You can now go out to dos and execute
manually your command to see what it is doing.

#2: You won't have to deal with any weird double quoting issues. Plus
you will not be dependent on any weird stuff the universe dos command
does.

#3: You will not run into any size limitation. The d3 ! command has a
buffer limit of something like 2000 characters. Therefore if your
entire command gets over that in size it truncates.

The following is my CURL routine that I have for my D3 Unix boxes.
With some tweaking it can be modified to run under dos and universe.
I have used it for a few years not. I use it to browse thru web sites
and AUTO-Fill out their pages. It does all sorts of things like.

a) Change the browser name to make the server think it is a IE
explorer
b) Save/persist cookies
c) handle timeouts
d) write out both output and sterr
e) grabs out redirects out of the cookie

As you can see in the code I originally directly executed the command.
I then modified to create a outside file when it got too big. I
eventually found it worked better that way and now it always does.

Example front end routine
OPTIONS='http://www.yahoo.com'
OPTIONS<2>='CREATE'
OPTIONS<3>='-F "field1=info" -F "field2=info2"
CALL CURL.RTNE(OPTIONS,RESULT)
COOKIE.ID=OPTIONS<2>
OPTIONS='http://www.yahoo.com/xxx'
OPTIONS<2>=COOKIE.ID; * PASS OLD COOKIE ID
CALL CURL.RTNE(OPTIONS,RESULT)


curl.rtne
SUBROUTINE CURL.RTNE(OPTIONS,RESULT)
$OPTIONS EXT
IF NOT(ASSIGNED(RESULT)) THEN RESULT=''
OPEN 'unix:/tmp/scripts' TO SCRIPT.FILE ELSE
EXECUTE '!mkdir /tmp/scripts'
OPEN 'unix:/tmp/scripts' TO SCRIPT.FILE ELSE RETURN
END
OPEN 'unix:/tmp/curl' TO CURL.FILE ELSE
EXECUTE '!mkdir /tmp/curl'
OPEN 'unix:/tmp/curl' TO CURL.FILE ELSE RETURN
END
OPEN 'RESULT.FILE' TO RFILE ELSE RETURN
* OPTIONS <1> = URL
* OPTIONS <2> = cookie (* CREATE to create cookie)
* OPTIONS <3> = OPTIONS
* OPTIONS <4> START DIRECTORY
* OPTIONS <5> = REDIRECT
IF OPTIONS<1>='' THEN
TEST=SYSTEM(33)
DEBUG.REC=TEST
DEBUG.REC<-1>=@USER.NO
DEBUG.REC<2>=OPTIONS
DEBUG.ID='DEBUG.':SYSTEM(19)
* WRITE DEBUG.REC ON RESULT.FILE, DEBUG.ID
RESULT=''
RETURN
END
WHOAMI=@USER
DOING.DEBUG=OPTIONS<20>
URL=OPTIONS<1>
COOKIE=OPTIONS<2>
IF COOKIE='' THEN COOKIE='CREATE'
OPTION=OPTIONS<3,1,1>
SESSION.ID=SYSTEM(19); * GET UNIQUE ID TO WRITE SCRIPT OUT AS
CMND='curl -s '
IF NOT(INDEX(OPTION,'-m',1)) THEN
CMND=CMND:' -m 45 '
END
CMND=CMND:' -v '
*CMND=CMND:'-o /tmp/curl/':SESSION.ID:'.output '
CMND=CMND:'--stderr /tmp/curl/':SESSION.ID:'.error '
UPDATE.COOKIE.ID=''
IF NOT(INDEX(OPTION,'-A',1)) THEN
CMND=CMND:' -A "Mozilla 4.0 (compatible; MSIE 5.5; Windows 98)" '
END
IF COOKIE='CREATE' THEN
COOKIE.ID=SYSTEM(19)
CMND=CMND:'-D /tmp/curl/':COOKIE.ID
OPTIONS<2>=COOKIE.ID
END ELSE
COOKIE.ID=COOKIE
CMND=CMND:'-b /tmp/curl/':COOKIE.ID
UPDATE.COOKIE.ID=COOKIE.ID:'.update'
CMND=CMND:' -D /tmp/curl/':UPDATE.COOKIE.ID
END
OUT.TEST=@USER.NO:CHAR(254):OPTIONS
IF OPTION<>'' THEN
CMND=CMND:' ':OPTION:' '
END
OUTPUT.ID=SESSION.ID:'.output'
FULL.OUTPUT.ID='/tmp/curl/':OUTPUT.ID
CMND=CMND:' -o ':FULL.OUTPUT.ID:' '
CMND=CMND:' "':URL:'"'
RESULT=CMND
* TRY TO DO THIS DIRECTLY NOW *
*TCL.CMND='!'
TCL.CMND=''
IF OPTIONS<4> <> '' THEN
TCL.CMND=TCL.CMND:'cd ':OPTIONS<4>:'; '
END
TCL.CMND=TCL.CMND:CMND
OPTIONS<6>=TCL.CMND
CONVERT CHAR(160) TO '' IN TCL.CMND
TCL.CMND='!':TCL.CMND
START.TIME=TIME()
IF LEN(TCL.CMND) > 1200 OR 1=1 THEN
** THIS IS TOO BIG, LETS WRITE IT OUT AND EXECUTE IT **
SCRIPT.ID=SYSTEM(19)
UNIX.TCL.CMND=TCL.CMND[2,LEN(TCL.CMND)]
WRITE UNIX.TCL.CMND ON SCRIPT.FILE, SCRIPT.ID
READ TEST FROM SCRIPT.FILE, SCRIPT.ID ELSE TEST=''
EXECUTE '!chmod a+x /tmp/scripts/':SCRIPT.ID
EXECUTE '!/tmp/scripts/':SCRIPT.ID CAPTURING RESULT
IF DOING.DEBUG THEN DEBUG
DELETE SCRIPT.FILE, SCRIPT.ID
END ELSE
EXECUTE TCL.CMND CAPTURING RESULT
END
END.TIME=TIME()
IF 1=1 THEN
ERROR.MSG=END.TIME-START.TIME:'|':OPTIONS<1>
LOG.NAME='!/var/log/curl.log'
* CALL WRITE.LOG(LOG.NAME,ERROR.MSG)
END
READ RESULT FROM CURL.FILE, OUTPUT.ID ELSE RESULT=''
DELETE CURL.FILE, OUTPUT.ID
READ STATUS.MSG FROM CURL.FILE, SESSION.ID:'.error' ELSE STATUS.MSG=''
DELETE CURL.FILE, SESSION.ID:'.error'
CONVERT CHAR(254) TO CHAR(253) IN STATUS.MSG
OPTIONS<9>=STATUS.MSG
IF UPDATE.COOKIE.ID<>'' AND 1=1 THEN
OPEN 'dos:/tmp/curl' TO CURL.FILE ELSE RETURN
READ ORIG.COOKIE FROM CURL.FILE, COOKIE.ID ELSE ORIG.COOKIE=''
READ NEW.COOKIE FROM CURL.FILE, UPDATE.COOKIE.ID ELSE NEW.COOKIE=''
END ELSE
OPEN 'dos:/tmp/curl' TO CURL.FILE ELSE RETURN
ORIG.COOKIE=''
READ NEW.COOKIE FROM CURL.FILE, COOKIE.ID ELSE NEW.COOKIE=''
END
NUMBER.LINES=DCOUNT(NEW.COOKIE,CHAR(254))+1
FOR X=1 TO NUMBER.LINES
LINE=NEW.COOKIE<X>
IF INDEX(LINE,'Set-Cookie:',1) THEN
ORIG.COOKIE<-1>=LINE
END
IF INDEX(LINE,'location:',1) THEN
POS=INDEX(LINE,':',1)
REDIRECT=LINE[POS+1,LEN(LINE)]
REDIRECT=TRIM(REDIRECT)
OPTIONS<5>=REDIRECT
END
IF INDEX(LINE,'Refresh:',1) AND INDEX(LINE,'URL=',1) THEN
POS=INDEX(LINE,'URL=',1)
IF POS THEN
REDIRECT=LINE[POS+4,LEN(LINE)]
REDIRECT=FIELD(REDIRECT,' ',1)
END
OPTIONS<5>=REDIRECT
END
NEXT X
IF UPDATE.COOKIE.ID<>'' THEN
WRITE ORIG.COOKIE ON CURL.FILE, COOKIE.ID
DELETE CURL.FILE, UPDATE.COOKIE.ID
END
POS=INDEX(RESULT,'<HTML>',1)
IF NOT(POS) THEN
POS=INDEX(RESULT,'<head>',1)
END
IF POS THEN
RESULT=RESULT[POS,LEN(RESULT)]
END
RETURN


"Louis Windsor" <lou...@tpg.com.au> wrote in message news:<3f76...@dnews.tpgi.com.au>...

0 new messages