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

I have a backend perl script that populates an array (@curl) and then calls curl using the 'open' command:

open CURL, "-|", @curl;

Is this allowed for a webpage or is it only allowed from the command line?
My program works perfectly from the command line, I really don't want to start changing everything to use www::curl.

Replies are listed 'Best First'.
Re: Calling open CURL, "-|", @curl from a webpage
by moritz (Cardinal) on Nov 30, 2009 at 16:46 UTC

    It is allowed unless forbidden - which depends on how your server is configured.

    Beware that doing that in a CGI script might cause a very slow page load for your user if the server it fetches from is slow, or the network connection to that server.

    Perl 6 - links to (nearly) everything that is Perl 6.
      Thank you
      So what would I need to change on the server in order to get it to work?
      Alternatively, what do I type on the command line to install the www::Curl library ('bubblegum' or something like that...I just can't remember the name. ).
      Also, how would I convert the following to use the www::Curl library?
      @curl = ('/usr/bin/curl', '-S','-v','--location', $url, '-H','Content- +Type:'.$content_type,'-H',"Authorization: $authorization",'-H',"X-Gda +ta-Key:$gdata_key",'-H',"Content-Length:$content_length",'-H','GData- +Version:2','--data',"\@$filename");
        So what would I need to change on the server in order to get it to work?
        So it doesn't work? In what way? Does it hang? Or do you get an error message? If yes, which? Is there anything in the error.log of your web server? Do you have selinux or a similar security enhancement installed? A firewall?
        Perl 6 - links to (nearly) everything that is Perl 6.
Re: Calling open CURL, "-|", @curl from a webpage
by afoken (Chancellor) on Nov 30, 2009 at 17:15 UTC

    Why do you think you need curl? The LWP::UserAgent and derived classes like LWP::Simple and LWP::RobotUA can do everything you need, all within your process, without needing to rely on external programs.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)