Wget download file ( do not overwrite )


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wget download file ( do not overwrite )
# 1  
Old 12-15-2013
Wrench Wget download file ( do not overwrite )

Hello all,

I want to write auto update script for my embedded device, which can check and download newer version of my program and extract the files on the device.
The download center is hosted on remote web server .

Script checks the hosted file on web site and if the new version is there then download it to the embedded device and extract the files in the dirs. But if the test.tar.gz is already downloaded and the files are already extracted then do nothing.

The embedded device runs Linux.

Example, this script actually does the work, but It replace the files all the time. I don't want to overwrite the files.

Code:
#!/bin/sh
wget http:xxx.myftp.org:2322/add/test.tar.gz
tar -zxvf test.tar.gz -C /
rm test.tar.gz

# 2  
Old 12-15-2013
My suggestion is to load up a "version file" together with the software bundle. You script would then download the version file first (the file would contain only the version as text), compare that to the version installed and then either do nothing or go through the update routine.

Something like:

Code:
#!/bin/sh
typeset -i installed="$(cat /etc/installed-version)"   # get version somehow
typeset -i update=0
wget http://xxx.myftp.org:2322/add/current-version
update=$(cat current-version)

if [ $update -gt $installed ] ; then
     wget http://xxx.myftp.org:2322/add/current-version
     tar -zxvf test.tar.gz -C /
     mv current-version /etc/installed-version       # update installed version
     rm test.tar.gz
fi

Probably not the most elegant solution, but you sure can start with that and add some elaboration, so i hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Old 12-15-2013
Yes you are right with the "version file", your solution will works.

Unfortunately I am running linux on embedded device and this command "typeset" does not exist.
# 4  
Old 12-15-2013
Hmm...

"typeset" is not a command, it is a shell internal, just like "if", "while", etc.. I suggest you simply try it. It is just to declare variables.

I hope this helps.

bakunin
# 5  
Old 12-16-2013
In other words, if your shell complains, remove the 'typeset -i' from in front of the variables and leave the rest.
This User Gave Thanks to Corona688 For This Post:
# 6  
Old 12-16-2013
Lets see now Smilie

---------- Post updated at 11:52 AM ---------- Previous update was at 11:20 AM ----------

It says error

[: 12: Illegal number:
# 7  
Old 12-16-2013
The script you were given only has 10 lines.

Show the script as you have it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wget download file content in unicode

Hi All, I am trying to download a XML from a URL through wget and successful in that but the problem is that I have to check for some special characters inside that XML. But when I download through wget it transfers the content of the XML in plain text and I'm not able to search for those... (2 Replies)
Discussion started by: dips_ag
2 Replies

2. Shell Programming and Scripting

[Solved] Wget command to download file

Hi I am trying to download the file using wget command. But The password was created as pwd$$ for the user xyz. When i give the command as below it is not downloading the file. Will the password has $$ causing this issue. wget... (0 Replies)
Discussion started by: ksmbabu
0 Replies

3. Shell Programming and Scripting

How to download file without curl and wget

Hi I need a Shell script that will download a zip file every second from a http server but i can't use neither curl nor wget. Can anyone will help me go about this task ??? Thanks!! (1 Reply)
Discussion started by: rubber08
1 Replies

4. Ubuntu

wget don't download complete file

I am using ubuntu 10.04 LTS I tried to download the file using wget , the file size is 105.00 MB, but wget downloads only around 44K. may be I am using wget in wrong way, any suggestions please? Below is the command I used and the response from system. wget --tries=10 -nd -nH --use=user... (10 Replies)
Discussion started by: LinuxLearner
10 Replies

5. Shell Programming and Scripting

Wget, download file from site's folder.

Ok, this is quite weird. wget -r mysite.com/mylink/ should get all the files recursively from the 'mylink' folder. The problem is that wget saves an index.html file! When I open this index.html with my browser I realize that it shows all the files in the current folder (plus an option to move... (3 Replies)
Discussion started by: hakermania
3 Replies

6. Shell Programming and Scripting

How to download to a file using wget in perl?

Hi, I want to download some online data using wget command and write the contents to a file. For example this is the URL i want to download and store it in a file called "results.txt". #This is the URL. $url="http://www.example.com"; #retrieve data and store in a file results.txt ... (3 Replies)
Discussion started by: vanitham
3 Replies

7. UNIX and Linux Applications

download file using wget

I need to download the following srs8.3.0.1.standard.linux26_32.tar.gz file from the following website: http://downloads.biowisdomsrs.com/srs83_dist There are many gzip files along with the above one in the above site but I want to download the srs8.3.0.1.standard.linux26_32.tar.gz only from... (1 Reply)
Discussion started by: alphasahoo
1 Replies

8. Shell Programming and Scripting

download a particular file using wget

Hi All I want to download srs8.3.0.1.standard.linux24_EM64T.tar.gz file from the following website : http://downloads.biowisdomsrs.com/srs83_dist/ But this website contains lots of zipped files I want to download the above file only discarding other zipped files. When I am trying the... (1 Reply)
Discussion started by: alphasahoo
1 Replies

9. UNIX for Dummies Questions & Answers

Using wget to download a file

Hello Everyone, I'm trying to use wget recursively to download a file. Only html files are being downloaded, instead of the target file. I'm trying this for the first time, here's what I've tried: wget -r -O jdk.bin... (4 Replies)
Discussion started by: thoughts
4 Replies

10. Shell Programming and Scripting

Script to download file using wget

Hi I need a Shell script that will download a text file every second from a http server using wget. Can anyone provide me any pointers or sample scripts that will help me go about this task ??? regards techie (1 Reply)
Discussion started by: techie82
1 Replies
Login or Register to Ask a Question