I’m scripting a call to curl, you can enter the password & parameters via STDIN (keep password off the cmd line).
I also need to send POST data on STDIN (large amount of data that won’t fit on the cmd line).
So, from a command line I can successfully do this by:
> curl -K --data-binary @- -other_non-pw_params
> -u "username:password"
> <User types ctrl-d>
> lots_of_post_data
> lots_of_post_data
> <User types ctrl-d>
> <User types ctrl-d>
Now… I’m trying to do that in a BASH script…
Wishful-thinking Psudo-code:
{ echo '-u "username:password"'
echo <ctrl-d> | cat dev/null | ^D
echo lots_of_post_data
echo lots_of_post_data
} | curl -K --data-binary @- -other_non-pw_params
Aha! There’s a curl specific solution to this.
You pass all of the parameters on STDIN, and leave –data-binary @- (or it’s equivalent) to the end, then everything after it is accepted as data input. Example script: