PHP and Perl

Discussion in 'PHP' started by Cep, Jul 20, 2005.

  1. #1
    Hi, i have search a lot and cant find an answer, i want that perl execute a php file, i have tried with this but doesnt works:

    #$FilePath = "http://localhost/~sparkiiflor/test/write.php?men=hola";
    #$file = "http://localhost/~sparkiiflor/test/write.php";
    open(INFO, $file) or die "Error\n";
    @lines = <INFO>;y
    close(INFO);
    print @lines;

    and with this
    system("write.php");

    But doesnt works, any idea???
     
    Cep, Jul 20, 2005 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,803
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #2
    blind leading the blind here but this has worked for me in the past
    #!/usr/local/bin/perl -w
    
    use LWP::Simple;
    use CGI;
    
    my $URL="http://mysite.net/process_cache.php";
    
    my $content = LWP::Simple::get($URL);
    
    print "$content";
    Code (markup):
     
    sarahk, Jul 21, 2005 IP
  3. UndiesHosting

    UndiesHosting Active Member

    Messages:
    219
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #3
    Yes that should work, but you don't need the use CGI; statement. You never call any methods from the package, so its not necessary.
     
    UndiesHosting, Jul 26, 2005 IP
    sarahk likes this.
  4. Discreet

    Discreet Guest

    Messages:
    550
    Likes Received:
    92
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If that doesn't work, this will:

    use WWW::Mechanize;

    my $mech = Mechanize->new();
    my $url = "http://www.yahoo.com";
    $mech->get($url);
    my $content = $mech->content();

    I use Mechanize over LWP because it has some other cool functions (it can submit forms, does wonders for testing checkouts lol).
     
    Discreet, Jul 28, 2005 IP
    sarahk likes this.