PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Curl Syntax  (Read 1943 times)

Mike Hatfield

  • Gold Member
  • ****
  • Posts: 67
    • View Profile
Curl Syntax
« on: May 22, 2019, 09:50:00 PM »
I am trying to specifiy the folder to download a file using Curl FTP
It uses the current folder by default.
I have trawled all the online doco but I cant find the syntax to specify the local destination.

LET MPROGRAM$="""\hit\pvx\curl.exe""",MDESTINATION$="ftp://ftp.hatfields.com.au/public_html/Future/Texts/"+TT$,MUSER$=%NW_WEB_USER$+ \

LET SS$=MPROGRAM$+" -k --ssl -O """+MDESTINATION$+""" --user """+MUSER$+"""       "

The above becomes:

"\hit\pvx\curl.exe" -k --ssl -O "ftp://ftp.domain.com.au/public_html/Future/Texts/mytestfile.txt" --user "username:password"

1. What is the syntax to specify the destination on the local computer?
I assume it's possible because *web/ftp can do it.
Unfortunately *web/ftp won't work with the new certificate requirements on ftp server. You always get an error.
I've had that discussion before, hence using Curl. The -k and --ssl parameters overcome the certificate issue.

2. Is there a syntax to specify all eg   *.txt files on the ftp server to download.
Again I can't find that either.
I did find ranges eg   [100-200].txt but that won't work in my case because the files names could be random.
I have resorted to retrieving a file ( ?.txt ) from the ftp server folder and parsing that for individual files.
Mike H


  • Member
  • **
  • Posts: 9
    • View Profile
Re: Curl Syntax
« Reply #1 on: May 23, 2019, 03:48:59 AM »
-O tells curl to download it to the current directory using the original filename (https://curl.haxx.se/docs/manpage.html#-O). Replace it with "-o /path/to/local/file" (https://curl.haxx.se/docs/manpage.html#-o).

For your second question, Google gave me 2 options:
Use -l to get the directory listing first, then use that to get all the files (https://curl.haxx.se/docs/manpage.html#-l).
Use something other than curl.

Devon Austen

  • Staff
  • Diamond Member
  • *****
  • Posts: 349
  • Don’t Panic
    • View Profile
    • PVX Plus Technologies
Re: Curl Syntax
« Reply #2 on: May 23, 2019, 08:12:07 AM »
I can confirm that it is -o /path/local that you want instead of -O.

cURL will not handle the * wildcard for you. You have to get the listing from the server and do the pattern match and then specify each file that matched the pattern to download from cURL. This is what *web/ftp has to do to support wildcards.

In a future release *web/ftp will support implicit and explicit FTP over SSL/TLS.
Software Developer for PVX Plus Technologies LTD.

Mike Hatfield

  • Gold Member
  • ****
  • Posts: 67
    • View Profile
Re: Curl Syntax
« Reply #3 on: May 23, 2019, 06:14:09 PM »

Thanks for the input.
I had worked out to download the folder contents and then parse it.
I had read about the -o but didn't realise you could specify the path.
So the bit I was missing was the local path.
Mike H