473,796 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 16 '05 #1
7 8463
"Matt Daleo" <az*****@yahoo. com> wrote in message
news:<_C******* ***********@new sread1.prod.itd .earthlink.net> ...

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?


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
Jul 16 '05 #2
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:32******** *************** ***@posting.goo gle.com...
"Matt Daleo" <az*****@yahoo. com> wrote in message
news:<_C******* ***********@new sread1.prod.itd .earthlink.net> ...

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?


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

Jul 16 '05 #3
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:32******** *************** ***@posting.goo gle.com...
"Matt Daleo" <az*****@yahoo. com> wrote in message
news:<_C******* ***********@new sread1.prod.itd .earthlink.net> ...

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?


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

Jul 16 '05 #4
"Matt Daleo" <az*****@yahoo. com> wrote in message
news:<C%******* ***********@new sread1.prod.itd .earthlink.net> ...

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:


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
Jul 16 '05 #5
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:32******** *************** **@posting.goog le.com...
"Matt Daleo" <az*****@yahoo. com> wrote in message
news:<C%******* ***********@new sread1.prod.itd .earthlink.net> ...

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:


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

Jul 16 '05 #6
"Matt Daleo" <az*****@yahoo. com> wrote in message
news:<%I******* ***********@new sread1.prod.itd .earthlink.net> ...
When I run the script this is the output that I get. I need
the missing data within the <textarea> tags:


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


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?


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
Jul 16 '05 #7
"Matt Daleo" <az*****@yahoo. com> wrote in message
news:<jx******* ***********@new sread1.prod.itd .earthlink.net> ...

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.


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

Cheers,
NC
Jul 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5909
by: Nick Bunton | last post by:
I have setup remote debugging on an NT4 workstation for testing. I then build from the debug config on my machine and copy all the files from the /bin/debug folder including the .PDB files. I then connect to the remote machine with VNC and start the application, once running from VS .NET on my development machine I connect to that process and the running app is shown in the IDE, but I cannot get the application to stop on any breakpoints...
4
2300
by: JoelWhitehouse | last post by:
Hi! I want to write a script that will read a .php file on a remote server and print to the current page a portion of the text contained in the remote file. I am just wondering what the best method is for reading from a file in this case - the file is only a few bytes long. I've seen a tutorial or two that only tangentially addresses my problem, and even then each one has varied greatly as to which object they utilize. Any ideas to...
0
3293
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS Remoting and possible others.
4
11277
by: Michael C | last post by:
Hi all, I'm trying to get a full directory listing from a remote machine. Anyone know how? Also, is it possible to read a file from a remote machine, like a ..TXT file or a .XML file in a specified directory without using the C$, D$, etc. or other shares? Finally, what rights would I need to read/write a registry key remotely? Thanks, Michael C.
2
17406
by: Adrian | last post by:
Hi I have some local pages (on PC harddisk) that act as a user interface and a set of JS files that controls it all. I now want to be able to access a remote web server to read a txt file and use the result in my local script. eg Remote text file i.e. conf.txt
7
1526
by: John Pote | last post by:
Hello, help/advice appreciated. Background: I am writing some web scripts in python to receive small amounts of data from remote sensors and store the data in a file. 50 to 100 bytes every 5 or 10 minutes. A new file for each day is anticipated. Of considerable importance is the long term availability of this data and it's gathering and storage without gaps. As the remote sensors have little on board storage it is important that a
4
1308
by: John Pote | last post by:
Hello, help/advice appreciated. Background: I am writing some web scripts in python to receive small amounts of data from remote sensors and store the data in a file. 50 to 100 bytes every 5 or 10 minutes. A new file for each day is anticipated. Of considerable importance is the long term availability of this data and it's gathering and storage without gaps. As the remote sensors have little on board storage it is important that a
29
3014
by: Jerim79 | last post by:
I did try to find the answer to this before posting, so this isn't a knee jerk reaction. What I am trying to accomplish is to have a script that opens a cookie, reads a value, and then use a switch/case to take action based on that value in the cookie. I want to set the cookie manually, so I don't need setcookie(). I see that in PHP it stores the cookie in memory. Is there a way to have PHP just read a cookie from the desktop machine?...
1
1408
by: barneymc | last post by:
Im wondering if anyone has come across a way of reading EventLogs using WMI. The event logs files are restored from another server. Below is the C# class that executes the query. NOTE : The event logs were created on a different (production) machine that I dont have access to. Is it possible to read these files viia WMI ? ManagementObjectSearcher searcher = null; //Maybe add the namespace as a parameter in the...
4
16103
by: Prof. William Battersea | last post by:
Hello, Suppose I have a Vista machine called VISTA and an XP machine called XP in a workgroup named WORKGROUP. Physically they're connected to a router and I can see lists of public and shared files on each of them. How do I address these for IO? A search suggested that the form open(r"\\server\folder\folder"), but I tried many combinations guessing what it wants for that path in my case (r"\\WORKGROUP\VISTA", "\\VISTA\PUBLIC", etc),...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9536
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10245
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4131
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.