script to check if file was downloaded


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users script to check if file was downloaded
# 1  
Old 03-06-2011
script to check if file was downloaded

I want to create a script to check if a file was downloaded into a folder. if it was i dont want to re-download it.

The requirement is as follows.
The first time the file (filename: A) is downloaded, it is renamed by stripping off part of the filename to filename A22.

The second time an attempt is made to download file A, it should not be downloaded, since it was downloaded and renamed already to A22.
# 2  
Old 03-08-2011
Well, you are filtering the file names to download, so where do you get those names?

Suppose the file names are date based: file_YYYY-MM-DD.data
Code:
FILE_LOC=file_$( date '+%Y-%m-%d' )
 
if [ ! -f $FILE_LOC ]
then
 scp rem_user@rem_host:drop_dir/$FILE_LOC.data $FILE_LOC.tmp
 zret=$?
 
 if [ $zret != 0 -o ! -s $FILE_LOC.tmp ]
 then
  echo "Download failed ($zret):" >&2
  ls -l $FILE_LOC.tmp >&2
  exit 1
 else
  mv $FILE_LOC.tmp $FILE_LOC
  echo "Download complete:" >&2
  ls -l $FILE_LOC >&2
 fi
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[Solved] Downloaded file is not correct format

Hi, Recently we migrated an application in HP UX to Linux. The files(scripts & logs)download from HP UX coming in a formatted way in MS notepad. However the files in Linux are not in correct format in MS notepad(No spaces , some spl symbols like square).We tried both ASCII and binary but no... (2 Replies)
Discussion started by: nag_sathi
2 Replies

2. Shell Programming and Scripting

extract fields from a downloaded html file

I have around 100 html files and in each html file I have 5-6 such paragraphs of a company and I need to extract the Name of the company from either the one after "title" or "/company" and then the number of employees and finally the location . <div class="search_result"> <div... (1 Reply)
Discussion started by: gubbu
1 Replies

3. UNIX for Advanced & Expert Users

howto remove meta info about MP4 or FLV file downloaded off Youtube?

Hi I tried a tool called mediainfo > brew info media-info media-info 0.7.51 http://mediainfo.sourceforge.net Depends on: pkg-config /usr/local/Cellar/media-info/0.7.51 (3 files, 14M) http://github.com/mxcl/homebrew/commits/master/Library/Formula/media-info.rb Got details from a test... (3 Replies)
Discussion started by: slashdotweenie
3 Replies

4. Programming

how to copy downloaded file into my source file folder (putty/unix)

I need to "Ensure that when you download libchat.a from the VLE you have copied it to the same folder on ius as your source files. You then refer to the library (and the libraries it needs) with: gcc -o outputfile sourcefile.c -L. -lchat -lsocket -lnsl" But I have no idea what this means! (I... (2 Replies)
Discussion started by: fakuse
2 Replies

5. Shell Programming and Scripting

Script to check for the file existence, if file exists it should echo the no of modified days

Hi, I am looking for a shell script with the following. 1. It should check whether a particular file exists in a location #!/bin/sh if ; then echo "xxx.txt File Exists" else echo "File Not Found" fi 2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies

6. Shell Programming and Scripting

To check wheather a file is downloaded completely or not

I will have two files (which were in .txt format) ftp'ed to a specified directory, from where my ksh picks up each file at a time and starts processing it. So i need to write a script which as soon as find a file should check wheather it is download completely or not. If it is still downloading... (2 Replies)
Discussion started by: vpv0002
2 Replies

7. UNIX for Advanced & Expert Users

Count total file downloaded using FTP

Hi All, I'm developing a FTP script as below: ftp -v -n <IP_ADDRESS> << EOF user avery jSqaqUU2 lcd /directory/folder/ ascii prompt mget * bye EOF I would like to enhance the script to count the total file downloaded. For example, once the script run i want the message "Total <n>... (1 Reply)
Discussion started by: cas553
1 Replies

8. UNIX for Dummies Questions & Answers

HELP! Accidentally downloaded .gz file non-binary

Let me start by saying I am at a VERY beginner level in terms of UNIX/FTP/etc. Someone loaded a file onto a server for me and zipped it using gzip. I accidentally downloaded the file without using "binary". I now have a "filename.txt.gz" sitting on my computer that I need to unzip. Is... (2 Replies)
Discussion started by: UDcc123
2 Replies

9. UNIX for Dummies Questions & Answers

Script to check for a file, check for 2hrs. then quit

I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit. Logically, I'm looking for the best way to approach this Thanks for any assistance in advance. Note: I'm using a C shell and... (2 Replies)
Discussion started by: mmarsh
2 Replies
Login or Register to Ask a Question