Results 1 to 7 of 7

Thread: Perl Execute Perl Script

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Perl Execute Perl Script

    I want to run one perl script like this


    Script.pl?one=one&two=two

    from the first perl script..

    I cant figure out a good way to do this.. I tried

    system()
    print qx|url|;

    and

    use URI;
    my $url = URI->new('' );


    Any ideas?

    Thanks!!

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    To execute another CGI script, you can, for example, send a request to your web server, though I don't know how in Perl.

    The problem with calling it directly is that you can't pass URL parameters the way you're used to, because these are parsed by the server and presented to your script in the way it expects. But you could do this parsing yourself, if you learn the way CGI works. The GET string (after the ? in the URL) is sent as command line parameter while the POST data is sent to stdin, so you'd have to open a pipe to the new process.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    ooo... ouch.

    I guess I dont know howto do that then.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    found a working way... try it.. its.. cool =-)

    PHP Code:
    use LWP::UserAgent;
                    
    # use HTTP::Request::Common qw(POST);

                    
    $ua = new LWP::UserAgent;
                    
    $ua->agent("Netscape 3.0");

                    
    $req = new HTTP::Request GET
                    
    =>"http://www.google.com/search?q=get+domain+perl&sourceid=mozilla-search&start=0&start=0&ie=utf-8&oe=utf-8";
                    print 
    "<h1>$url</h1>";

                    
    # Pass request to the user agent and get a response back
                    
    $res $ua->request($req);

                    
    # Put the response into a page array
                    
    @page $res->content;

                    print 
    "<br> page = @page   |||||"

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    I guess that type code is not capable of SSL, and SSL is what I need. So Im still lost

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    i just read LWP is capable of some kind of HTTPS SSL, so ill post that when I find it.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Debian Install These:

    sudo apt-get install libnet-ssleay-perl libcrypt-ssleay-perl libwww-perl

    PHP Code:
    my $uri "https://www.mysite.com/";
                    
    #require CGI::Test::Input::URL;
                    #my $input = CGI::Test::Input::URL->new("$url");
                    #use LWP::UserAgent;
                    #my $response = LWP::UserAgent->new->get("/usr/share/XIII/update-default-sql-ledger.pl?masternum=$masternum&trans_id=$paymentno&transtype=0");
                    #print "/usr/share/XIII/update-default-sql-ledger.pl?masternum=$masternum&trans_id=$paymentno&transtype=0";
                    
    use LWP::UserAgent;


                    
    my $ua LWP::UserAgent->new;
                    
    my $req HTTP::Request->new(GET => $uri);
                    
    my $res $ua->request($req);

                    if (
    $res->is_success) {

                    print 
    $res->as_string;

                    } else {

                    print 
    "Failed to GET '$uri': "$res->status_line"\n";
                    } 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width