Hello monks,
Although I've used the site for tips for about a year, this is my first posting, so excuse me if I am not following correct protocol.
I have a problem that I can't figure out. I am programming in a windows environment, and I am trying to write a simple script that will run several curl commands.
My problem occurs when I run a curl command that needs a response (example "Enter host password for user 'username':").
I can't figure out how to actually send the password to curl.
I've tried several different methods but none have worked for me. Here is a snippet from my latest attempt:
my ($pid, $writeme);
for(0..4){
$pid = open $writeme, "|-",
"c:\\apps\\curl\\curl -u user$_ -X DELETE http://localhost:300
+0/site/users/user$_";
sleep 2;
print $writeme "password$_\r"; #curl isn't receiving this input
close $writeme; #perl hangs here
sleep 1;
}
The password that I send by printing to $writeme isn't being seen by curl for some reason, which leaves curl in a "waiting for input state".
If anyone could show me how I can fix this, I would be immensely grateful.
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.