[Tfug] bash dl script

Nate nate at torzo.com
Mon Aug 25 14:40:20 MST 2008


script.sh
-----------------------
#!/bin/sh

# Get date... see 'man date' for format string
DATE=`date +"%Y-%m-%d"`
URL="http://www.somesite.com/files/some_file_$DATE.ext"
OUT="/tmp/some_file_$DATE.ext"

wget -O $OUT $URL
-----------------------

chmod +x script.sh

Then cron it to run, like every 5 minutes:

*/5 * * * * /path/to/script.sh

Adjust everything as needed of course.

Nate

christopher wrote:
> can anyone recommend a good tutorial about creating
> scripts that regularly download files via http?
> 
> I'm not a regular bash user, but I have a bash manual.
> If another language is recommended, that won't be a
> major problem either.
> 
> basically I assume that I need to figure out how to
> open a socket to connect to the file's webserver, and
> then request the file and save it somewhere.
> 
> The files follow a predictable naming scheme, which
> includes the date as part of its name. I plan to parse
> something like the 'date' command to specify the date
> and month part of the file name.
> 
> I think that covers the specs. Thanks for any help
> 

-- 
Nate
System Admin Manager
System Administration
Ext 220




More information about the tfug mailing list