Posts tonen met het label Storage. Alle posts tonen
Posts tonen met het label Storage. Alle posts tonen

donderdag 14 december 2017

wget and curl tips

Imagine you want to download all files under http://www.example.com/2013/downloads, and not files under http://www.example.com/2013 except for directory 'downloads', then you can do this:
wget -r --level 100 -nd --no-proxy --no-parent --reject "index.htm*" --reject "*gif" 'http://www.example.com/2013/downloads/' #--level 100 is large enough, as I've seen no site has more than 100 levels of sub-directories so far.
wget -p -k --no-proxy --no-check-certificate --post-data 'id=username&passwd=password' <url> -O output.html
wget --no-proxy --no-check-certificate --save-cookies cookies.txt <url>
wget --no-proxy --no-check-certificate --load-cookies cookies.txt <url>
curl -k -u 'username:password' <url>
curl -k -L -d id=username -d passwd=password <url>
curl --data "loginform:id=username&loginform:passwd=password" -k -L <url>
curl -i -u username:password -H X-Oracle-UserId:myname@example.com -H X-Oracle-IdentityDomain:domainname -X GET "https://login.example.com:443/api/v1/users?userLogin"
Here's one curl example to get SSL certs info on LTM:
#!/bin/bash
path="/var/tmp"
path_root="/var/tmp"
agent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.2)"
curl -v -L -k -A "$agent" -c ${path}/cookie "https://ltm-url/tmui/login.jsp?msgcode=1&"
curl -v -L -k -A "$agent" -b ${path}/cookie -c ${path}/cookie -e "https://ltm-url/tmui/login.jsp?msgcode=1&" -d "username=myusername&passwd=mypassword" "https://ltm-url/tmui/logmein.html?msgcode=1&"
curl -v -L -k -A "$agent" -b ${path}/cookie -c ${path}/cookie -o ${path_root}/certs-env.html "https://ltm-url/tmui/Control/jspmap/tmui/locallb/ssl_certificate/list.jsp?&startListIndex=0&showAll=true"
Now you can have a check of /var/tmp/certs-env.html for SSL certs info of Big IP VIPs.
PS:
To use private CA/public cert/private key, you should use below in curl:
curl -v --cacert your-root-ca.crt --cert your-public-cert.crt --key your-private.key --pass mypass -u "username:password" https://url
In this command, your-public-cert.crt is the public cert that you have trusted,your-private.key is the private RSA key portion of the cert that is used to sign the request, and “username:password” should be replaced with the correct username and password.
Also, if you’re using an intermediate cert, you can provide it in one command like so:
curl -v --cacert your-root-ca.crt --cert <(cat your-public-cert.crt  intermediate.crt ) --key your-private.key --pass mypass -u “username:password" https://url