Skip to content

Instantly share code, notes, and snippets.

@xkr47
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkr47/2b0a1338067bc200e0ae to your computer and use it in GitHub Desktop.
Save xkr47/2b0a1338067bc200e0ae to your computer and use it in GitHub Desktop.
Feed username/password to curl without temporary files and without showing in process list
# usage: curlum <username> <password> <curl args...>
curlum () {
user="$1"
pass="$2"
shift 2
curl --config /dev/fd/3 "$@" 3<<EOF
--user $user:$pass
EOF
}
# example
USER=foo
PASS=bar
curlum $USER $PASS http://localhost:1234/index.html
@xkr47
Copy link
Author

xkr47 commented Dec 31, 2014

Works also together with --data @- like this:

SECRET="1v4yu991h4c"
curlum $USER $PASS --data @- http://localhost:1234/index.html <<EOF
foo=bar&super=$SECRET
EOF

@xkr47
Copy link
Author

xkr47 commented Dec 31, 2014

Apparently the --netrc-file option was added in curl 7.21.5. Script updated to use --config instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment