Reading remote files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Daleo

    #1

    Reading remote files

    I'm attempting to read a remote file and parse it for data. The problem I'm
    having is that the file seems to be generated by Perl
    (http://alert.dot.pima.gov/scripts/1brpssd.pl) and when I read it the
    script-generated data is not displayed. When I view the page with a browser
    the data is displayed just fine. I've tried using the built-in PHP commands
    to read the file (file, fget) as well as the all of the Snoopy "fetch"
    classes (http://snoopy.sourceforge.net). Any ideas?

    Thanks.

    M


  • Nikolai Chuvakhin

    #2
    Re: Reading remote files

    "Matt Daleo" <azdaleo@yahoo. com> wrote in message
    news:<_CSZa.694 5$M6.533042@new sread1.prod.itd .earthlink.net> ...[color=blue]
    >
    > I'm attempting to read a remote file and parse it for data. The problem
    > I'm having is that the file seems to be generated by Perl
    > (http://alert.dot.pima.gov/scripts/1brpssd.pl) and when I read it the
    > script-generated data is not displayed. When I view the page with a browser
    > the data is displayed just fine. I've tried using the built-in PHP commands
    > to read the file (file, fget) as well as the all of the Snoopy "fetch"
    > classes (http://snoopy.sourceforge.net). Any ideas?[/color]

    Try this:

    $host = 'alert.dot.pima .gov';
    $path = '/scripts/1brpssd.pl';
    $fp = fsockopen ($host, '80');
    if ($fp) {
    fputs ($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n\r \n");
    while (!feof($fp)) {
    echo fgets ($fp, 10240);
    }
    } else {
    echo "Oops... Didn't work... ";
    }

    Cheers,
    NC

    Comment

    • Patrick

      #3
      Re: Reading remote files

      Is there anyway to get the script to not display the header/get information?
      ie: HTTP/1.1 200 OK Date: Tue, 12 Aug 2003 03:31:17 GMT Server:
      Apache/2.0.40 (Red Hat Linux) Accept-Ranges: bytes X-Powered-By: PHP/4.2.2
      Content-Length: 111 Connection: close Content-Type: text/html;
      charset=ISO-8859-1

      And just display the content of the page?
      Your script works perfect for my application, I would just like to figure
      out how to remove the http information.

      Thanks-

      "Nikolai Chuvakhin" <nc@iname.com > wrote in message
      news:32d7a63c.0 308111850.64244 8e8@posting.goo gle.com...[color=blue]
      > "Matt Daleo" <azdaleo@yahoo. com> wrote in message
      > news:<_CSZa.694 5$M6.533042@new sread1.prod.itd .earthlink.net> ...[color=green]
      > >
      > > I'm attempting to read a remote file and parse it for data. The problem
      > > I'm having is that the file seems to be generated by Perl
      > > (http://alert.dot.pima.gov/scripts/1brpssd.pl) and when I read it the
      > > script-generated data is not displayed. When I view the page with a[/color][/color]
      browser[color=blue][color=green]
      > > the data is displayed just fine. I've tried using the built-in PHP[/color][/color]
      commands[color=blue][color=green]
      > > to read the file (file, fget) as well as the all of the Snoopy "fetch"
      > > classes (http://snoopy.sourceforge.net). Any ideas?[/color]
      >
      > Try this:
      >
      > $host = 'alert.dot.pima .gov';
      > $path = '/scripts/1brpssd.pl';
      > $fp = fsockopen ($host, '80');
      > if ($fp) {
      > fputs ($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n\r \n");
      > while (!feof($fp)) {
      > echo fgets ($fp, 10240);
      > }
      > } else {
      > echo "Oops... Didn't work... ";
      > }
      >
      > Cheers,
      > NC[/color]


      Comment

      • Matt Daleo

        #4
        Re: Reading remote files

        Thanks for the script. I've tried it and it works great with other web
        pages, but still doesn't seem to work with the particular page that I need.
        When I run the script this is the output that I get. I need the missing data
        within the <textarea> tags:

        HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Date: Tue, 12 Aug 2003 04:24:15
        GMT Content-Type: text/html <html> <head> <title>Map 1 Upper Cañada del Oro
        sensors</title> </head> <body> <body background=/DWGraphics/DWBG.jpg> <div
        align=Center><f ont size=+2
        color=#551a8b>< big><big><big>< big><big><big>< big><big><big>< big><big><big>< b
        ig><big><big> Map 1 Upper Cañada del Oro
        Sensors</big></big></big></big></big></big></big></big></big></big></big></b
        ig></big></big></big></font><br> </div> &nbsp &nbsp <div align=Center><f ont
        size=5 color=#551a8b> Hourly Rainfall for 0 Periods For Sensors In Map 1
        Upper Cañada del Oro </font><br> </dev> <td> <FORM METHOD=POST> <TEXTAREA
        NAME=Data ROWS=25 COLS=100 WRAP=OFF READONLY> </TEXTAREA> </FORM> </body>
        <center> <a href=Pima.pl><b ><font size=4>Main Map</font></b></a> &nbsp &nbsp
        &nbsp <a href=2brpssd.pl ><b><font size=4>Map 2</font></b></a> &nbsp &nbsp
        &nbsp <a href=3brpssd.pl ><b><font size=4>Map 3</font></b></a> &nbsp &nbsp
        &nbsp <a href=4brpssd.pl ><b><font size=4>Map 4</font></b></a> &nbsp &nbsp
        &nbsp <a href=5brpssd.pl ><b><font size=4>Map 5</font></b></a> </center>
        </html>

        Thanks.

        M

        "Nikolai Chuvakhin" <nc@iname.com > wrote in message
        news:32d7a63c.0 308111850.64244 8e8@posting.goo gle.com...[color=blue]
        > "Matt Daleo" <azdaleo@yahoo. com> wrote in message
        > news:<_CSZa.694 5$M6.533042@new sread1.prod.itd .earthlink.net> ...[color=green]
        > >
        > > I'm attempting to read a remote file and parse it for data. The problem
        > > I'm having is that the file seems to be generated by Perl
        > > (http://alert.dot.pima.gov/scripts/1brpssd.pl) and when I read it the
        > > script-generated data is not displayed. When I view the page with a[/color][/color]
        browser[color=blue][color=green]
        > > the data is displayed just fine. I've tried using the built-in PHP[/color][/color]
        commands[color=blue][color=green]
        > > to read the file (file, fget) as well as the all of the Snoopy "fetch"
        > > classes (http://snoopy.sourceforge.net). Any ideas?[/color]
        >
        > Try this:
        >
        > $host = 'alert.dot.pima .gov';
        > $path = '/scripts/1brpssd.pl';
        > $fp = fsockopen ($host, '80');
        > if ($fp) {
        > fputs ($fp, 'GET '.$path." HTTP/1.0\r\nHost: ".$host."\r\n\r \n");
        > while (!feof($fp)) {
        > echo fgets ($fp, 10240);
        > }
        > } else {
        > echo "Oops... Didn't work... ";
        > }
        >
        > Cheers,
        > NC
        >[/color]


        Comment

        • Nikolai Chuvakhin

          #5
          Re: Reading remote files

          "Matt Daleo" <azdaleo@yahoo. com> wrote in message
          news:<C%ZZa.812 8$M6.617108@new sread1.prod.itd .earthlink.net> ...[color=blue]
          >
          > Thanks for the script. I've tried it and it works great with other web
          > pages, but still doesn't seem to work with the particular page that I need.
          > When I run the script this is the output that I get. I need the missing data
          > within the <textarea> tags:[/color]

          I just opened the URL you are trying to retrieve in browser and reloaded
          it several times. There is no data in <textarea>...

          Cheers,
          NC

          Comment

          • Matt Daleo

            #6
            Re: Reading remote files

            You're right. When you go directly to the page there is no data, but if you
            go in through the main page and navigate to it the data is there. Is there a
            way to check the headers to see if it's passing session variables? Or is it
            another issue?

            Thanks.

            M

            "Nikolai Chuvakhin" <nc@iname.com > wrote in message
            news:32d7a63c.0 308121137.6a836 05@posting.goog le.com...[color=blue]
            > "Matt Daleo" <azdaleo@yahoo. com> wrote in message
            > news:<C%ZZa.812 8$M6.617108@new sread1.prod.itd .earthlink.net> ...[color=green]
            > >
            > > Thanks for the script. I've tried it and it works great with other web
            > > pages, but still doesn't seem to work with the particular page that I[/color][/color]
            need.[color=blue][color=green]
            > > When I run the script this is the output that I get. I need the missing[/color][/color]
            data[color=blue][color=green]
            > > within the <textarea> tags:[/color]
            >
            > I just opened the URL you are trying to retrieve in browser and reloaded
            > it several times. There is no data in <textarea>...
            >
            > Cheers,
            > NC
            >[/color]


            Comment

            • Nikolai Chuvakhin

              #7
              Re: Reading remote files

              "Matt Daleo" <azdaleo@yahoo. com> wrote in message
              news:<%Ic_a.922 4$M6.756854@new sread1.prod.itd .earthlink.net> ...[color=blue]
              >[color=green][color=darkred]
              > > > When I run the script this is the output that I get. I need
              > > > the missing data within the <textarea> tags:[/color]
              > >
              > > I just opened the URL you are trying to retrieve in browser and reloaded
              > > it several times. There is no data in <textarea>...[/color]
              >
              > You're right. When you go directly to the page there is no data, but if you
              > go in through the main page and navigate to it the data is there. Is there a
              > way to check the headers to see if it's passing session variables? Or is it
              > another issue?[/color]

              Most likely (just by the looks of it), the Perl scripts set cookies.
              You can deal with this system using cURL, but you will have to program
              cURL to more or less precisely imitate the sequence of page loads you
              accomplish with your browser.

              Cheers,
              NC

              Comment

              • Nikolai Chuvakhin

                #8
                Re: Reading remote files

                "Matt Daleo" <azdaleo@yahoo. com> wrote in message
                news:<jxe_a.944 3$M6.775682@new sread1.prod.itd .earthlink.net> ...[color=blue]
                >
                > I've figured it out. The HTML headers need to read as follows:
                >
                > GET /scripts/1brpssd.pl HTTP/1.1 Host: alert.dot.pima. gov
                > Cookie: pimafile=-Inetpub-Scripts-DWTemp-config106072816 6.txt
                >
                > It looks to me like they're using a cookie to activate a script
                > of some kind.[/color]

                I don't think so. Rather, the cookie contains a reference to a data
                file, which the script retrieves and displays.

                Cheers,
                NC

                Comment

                Working...