Jump to content

Script to download a file from HTTP server using wget


Recommended Posts

How about this:

 

#!/bin/bash
COUNTER=0
while [ 1 ]; do
	wget -O file${COUNTER} http://server/file
	let COUNTER=COUNTER+1
	sleep 1s
done

 

This downloads http://server/file every second, and saves each file as file0, file1, file2, file3...

 

If you don't need to keep the old ones, just remove the -O file${COUNTER} bit.

 

This will run forever, until you press Ctrl-C at the terminal.

Link to post
Share on other sites

Actually wget automatically increments on the filename if it already exists. So no need for a counter :) Also its always better to use sh for the shellscripts (makes it portable code). Thus:

 

#!/bin/sh
while [ 1 ]
do
 wget http://server/file
 sleep 1s
done

 

Yay ... nice one hybrid.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...