heiths39 has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use curl to hit Jira REST API. I don't want to feed via command line users password. So I'm trying to feed the password to curl. DOesn't seem to be working.

my $u="USERNAME"; my $p="PASSWORD"; my $key="JIRA-NUMBER"; my $tempURL="/usr/bin/curl --user $u \"http://jira.company.com/rest/ap +i/latest/search?jql=KEY%20IN%20($key)\""; open (INFO,"|-", $tempURL); sleep 1; print INFO $p; my @DATAIN=<INFO>; print @DATAIN; my $data = join("",@DATAIN); print "What is data $data\n";
Always returns back an Unauthorized (401). I have tried many things. I tried feeding it a "\n" to. Tried using just "| ". Tried with and without sleep. I'm just not getting what is wrong. P.S. Also it clearly is asking for the password I can see the text and it returning the text from jira.

Replies are listed 'Best First'.
Re: open and curl
by choroba (Cardinal) on Jun 10, 2015 at 13:31 UTC
    The man page for curl shows the format for the password as
     -u, --user <user:password>
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: open and curl
by dave_the_m (Monsignor) on Jun 10, 2015 at 17:07 UTC
    Curl doesn't read the password from stdin, it opens /dev/tty and reads from that. So you'll probably need to use something like Expect.

    Dave.

      I only need one way communication with curl. Anyway to complete that. With out any additional modules. Process to get additional modules is long take weeks or months.
        In that case I guess you'll have to implement a subset of the functionality found in IO::Pty. Or use the -n option to curl and store the password in .netrc. Or use HTTP::Tiny like someone suggested above.

        Dave.

Re: open and curl
by Anonymous Monk on Jun 10, 2015 at 14:41 UTC