Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Download a file and manipulate it

Status
Not open for further replies.

webdude2

IS-IT--Management
Joined
Jun 18, 2004
Messages
1
Location
US
Hi folks. Here's what I need to do and I really don't know how to do it.

I need to download a file via HTTP to my server and run a find a replace on some test strings and name it data.txt. I need this done every day at 1AM. I can use cron to have a script run every day but I don't really have the knowledge to program such a script. If anyone knows where I can get ahold of such a script I'd appreciate the help.
 
1. Download a file to your server via HTTP.
Assumption: You have permission to download the data and do not violate any copyright or other laws by doing so (thanks to jimoblak to remind everyone of this!).
Use cURL functions of a socket. The PHP manual has explicit examples how to open a socket and send a HTTP request.

2. Hold the content in a string and perform your replacements using regular expressions.

3. Open a file stream and save the result.

4. Best is to have PHP as command line so you can trigger it with cron. There are workarounds where you can spawn e.g.Lynx and visit the script and trigger it. However, then you need a mechanism to make sure it only can be accessed once a day (to prevent abuse).
 
sleipnir214
I see, you understood the post differently. It wasn't clear to me that it might be an upload! I immediately thought of the screen-scraping scenario.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top