cURL notes:
official web sites:
curl: http://curl.haxx.se
http://curl.siamu.ac.th/docs/httpscripting.html
openssl: http://www.openssl.org
Curl is an open source command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP. Curl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and a busload of other useful tricks. Openssl handles the encryption part of the transfer.
Curl usage:
TO use config file ( _culrc ) the next line must be set in the batch file or scripting environment.
set home=c:\directory_pathto_config_file
Since curl will only work with PEM formatted certificates, we need to convert the PKCS12 format certificate:
openssl pkcs12 -in [original certificate file] -clcerts -out [PEMfile]
I believe some web sites use cookies for the session timeout (I believe a 5-10 minute timeout period). For that reason when initially communicating with the server we MUST run 2 passes of curl, 1 to authenticate and 1 to do the transfer or whatever other command we want to issue.
Using config file:
list directory:
curl https://this.secretwebsite.com/* -- will list everything recursively; lists just file/path names
curl https://this.secretwebsite.com -- is like doing an ls -l
download:
curl -O https://this.secretwebsite.com/outbound/SFT_Win32_4.0.39_Guide.doc
upload:
curl -T mylocalfile.txt https://this.secretwebsite.com/
files we get back: mylocalfile.txt_201706.NO_ADD_REC
that's HHMMSS (maybe pacific timezone)
Deleting files:
curl -X DELETE https://this.secretwebsite.com/mylocalfile.txt_201706.NO_ADD_REC
from manual-
-X/--request <command>
(HTTP) Specifies a custom request to use when com
municating with the HTTP server. The specified
request will be used instead of the standard GET.
Read the HTTP 1.1 specification for details and
explanations
_culrc (config file) contents:
#cookie send file (-b)
cookie C:\sys\temp\curl\cookie.jar
#cookie receive file (-c)
cookie-jar C:\sys\temp\curl\cookie.jar
#redirect to different location (-L)
location
#certificate file and pw for authenication (-E)
cert e:\curl\mysecrets.pem:the_password_goes_here
#display progress bar (-#) instead of default statistics
progress-bar
#Write output to a local file named like the remote file we get.
#(Only the file part of the remote file is used, the path is cut off.)
#remote-name
No comments:
Post a Comment