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

Hi monks,
$mailstr = "$GETURL -d \"$SECURITY\" http://$SERVER$SUBSCRIPT?id=$code +"; print "\n$mailstr\n"; $mail = `$mailstr`;
I am trying to get the contents of that file into the variable $mail

The print outputs
/usr/local/bin/urlget -d "username=matt&password=yeahright" http://mat +t/functions/financial/templates/textinvoice.asp?id=GDI
If I take that and execute it on the prompt it returns the page on STDIO and finishes, no problem. However perl waits around indefinately until I press CTRL-D then continues

wtf

Replies are listed 'Best First'.
Re: backticks command just waits
by dga (Hermit) on Aug 26, 2001 at 19:58 UTC

    I think you will be happier with the LWP::Simple module available in CPAN to get http documents into your perl programs since it gives you better control of the process and also you can find out better what happened and you can set a timeout in case the remote site doesn't respond in time.

      thanks for the idea. I will probably try that in the future.
Re: backticks command just waits
by troll314 (Initiate) on Aug 26, 2001 at 19:57 UTC
    Ignore what I said... I'm just confused. It was another backticks command causing it to wait.

    viz. $FROMADDR = `sed -n s/[fF]rom://p`;
    lol
Re: backticks command just waits
by jlongino (Parson) on Aug 26, 2001 at 20:46 UTC
    Just a guess, but something is waiting for end-of-input which may be supplied by the Enter key from the prompt. I don't know if it will work or not, but you might try appending a chr 10 or a chr 4 to your command. E.g.,

    $mailstr .= chr 4;
    If the code and the comments disagree, then both are probably wrong. -- Norm Schryer
      thought about that too. i haven't tried it either but yeah it could work. I got it working now anyway. Just pulled out the sed call. It was there cos I was converting a bash script.