Subscribe Bookmark



Mar 21, 2013

Web site wants a password

Question from @billkopp.

Using cURL to supply basic authentication credentials.  Replace "user" and "pass"  appropriately.  Remove the -k if you don't need it; it bypasses the checking for a valid signing authority on an https site's certificate (you probably know if you are using a self-signed certificate...then you'll need it).  DO use https if available; it will keep others from seeing the password...unless your script is left on your screen...

The example assumes Windows users put a copy of curl.exe on the desktop.  Mac users are good to go.

The last two lines open the downloaded CSV in JMP and do some basic error reporting.



if( HostIs("Windows"),
  data = RunProgram(
  executable( Convert File Path( "$desktop", windows ) || "curl.exe" ),
  options( "-k -s -u user:pass --basic" ),
  readfunction( "blob" )
, // else mac version
  data = RunProgram(
  executable( "/usr/bin/curl" ),
  options( {"-k", "-s", "-u", "user:pass", "--basic", ""} ),
  readfunction( "blob" )
try( dt = open(data, "text"); error="", error=exception_msg; dt=empty() );



Article Tags