CURL - Unix, Linux Command
CURL - Unix, Linux Command
Thursday, November 23, 2017
12:45 PM
EXAMPLES
To send your password file to the server, where 'password' is the name of the form-field to which /etc/passwd will be the input:
$ curl -F password=@/etc/passwd www.mypasswords.com
To retrieve a web page and display in the terminal
$ curl http://www.tutorialspoint.com
To retrieve a web page and display header information
$ curl http://www.tutorialspoint.com -i
To retrieve a web page and save to a file.
$ curl http://www.tutorialspoint.com -0 tutorialspoint.html
To retrieve a web page, or its redirected target
$ curl www.tutorialspoint.com/unix/
$ curl www.tutorialspoint.com/unix/ --location
To limit the rate of data transfer to 1 Kilobytes/sec
$ curl http://www.tutorialspoint.com/unix/ --limit-rate 1k -o unix.html
To download via a proxy server
$ curl -x proxy.example.com:3128 http://www.tutorialspoint.com/unix/
Inserted from <http://www.tutorialspoint.com/unix_commands/curl.htm>
HTPS:
The web site likely uses cookies to store your session information. When you run
curl --user user:pass https://xyz.com/a #works ok
curl https://xyz.com/b #doesn't work
curlis run twice, in two separate sessions. Thus when the second command runs, the cookies set by the 1st command are not available; it's just as if you logged in to page a in one browser session, and tried to access page b in a different one.
What you need to do is save the cookies created by the first command:
curl --user user:pass --cookie-jar ./somefile https://xyz.com/a
and then read them back in when running the second:
curl --cookie ./somefile https://xyz.com/b
Alternatively you can try downloading both files in the same command, which I think will use the same cookies.
ALT HTTPS:
curl -c cookie.txt -d "LoginName=someuser" -d "password=somepass" https://oursite/a
curl -b cookie.txt https://oursite/b
Created with Microsoft OneNote 2016.
comments powered by Disqus