Posted on 12-03-2015 09:10 AM
Hello All,
I am working on a script to curl something but we are using a .pac file,is this possible? If so anyone know how to?
Solved! Go to Solution.
Posted on 12-03-2015 02:49 PM
Just to clarify, you can permanently set your proxy URL for use with terminal commands, but it won't work with PAC files. Refer to How to set proxy environment variable in Unix/Linux if you aren't already aware of how to do this.
Posted on 12-03-2015 11:25 AM
As far as I know, no, curl doesn't support using javascript. I'm assuming that this script will be run from various networks and you won't know which proxy to use, hence the reliance upon the .pac file? You are able to supply curl with a proxy manually via the -x option but if that proxy will not apply to all situations, then I guess you're outta luck.
More here:
http://curl.haxx.se/docs/faq.html#Does_curl_support_Javascript_or
Posted on 12-03-2015 11:29 AM
I think you could use a script:
#!/bin/sh
networksetup -setautoproxyurl Ethernet http://link/to.pac
Posted on 12-03-2015 11:58 AM
You would need to find the address of the proxy server that the PAC file points to when it is executed, then set your environment variables (http_proxy, https_proxy) to point to that server.
If you have Kerberos authentication enabled on your proxy, you should be able to just do a kinit
to get a Kerberos ticket, then open Safari and go to Google to generate a kerberos ticket for the proxy. You can confirm that a ticket was issued by using klist
. Once complete, you can test using curl http://www.google.com
. If done correctly, you'll get a long string of HTML/JavaScript. If not, you'll probably get a "host not found" or "proxy authentication required" error.
If you don't have Kerberos enabled, you would need to include credentials in the proxy environment variable string.
Posted on 12-03-2015 12:20 PM
Thanks everyone for the replies!
The pac file for the OS is already set, and surfing the web is no problem. If you want to use terminal and curl a file that's where there is an issue.
so if I did
"curl --silent http://server.com"
this won't resolve, but if I take that url and stick it in a browser it does work.
Posted on 12-03-2015 02:49 PM
Just to clarify, you can permanently set your proxy URL for use with terminal commands, but it won't work with PAC files. Refer to How to set proxy environment variable in Unix/Linux if you aren't already aware of how to do this.
Posted on 12-03-2015 02:51 PM
Thanks @dwandro92