Sponsored Content
Top Forums Shell Programming and Scripting How to check if downloading of a file is completed? Post 302989088 by looney on Saturday 7th of January 2017 01:47:23 PM
Old 01-07-2017
How to check if downloading of a file is completed?

Hello All.
We are getting one zip file from another server daily. The size of the zip file will be around 4.5 gb that takes time to download completely. I have to process that file furthest once get downloaded completely. I have written one code for that, but i need suggestion whether it is a right approach or any better way with no surprises. Kindly suggest
Thanks in Advance

I am comparing size of file after every 60 seconds.

Code:
#creating function
_func() {

x=`du -sk "$path" | awk '{ print $1 }'`
sleep 5
y=2

while [ "$x" != "$y" ]
do
y=`du -sk "$path" | awk '{ print $1 }'`
echo "size before sleep is $y"
echo "sleep for another 60 seconds"
sleep 60
x=`du -sk "$path" | awk '{ print $1 }'`
echo "size after sleep $x"
done

}

#using function
if _func ; then
echo "downloading is complete"
else
echo "downloading"
fi

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Downloading Excel File

Hello All, Currently working with CGI scripts in perl which involves a) uploading b) processing c) downloading the file back to the user uploading and processing quite trivial and they are done Third part is kind of being tricky. Excel file in binary format is getting displayed in the... (4 Replies)
Discussion started by: matrixmadhan
4 Replies

2. Shell Programming and Scripting

Downloading a csv file automatically

I want to automatically download a CSV file daily which can be found here: London Stock Exchange - Search and the link is named "Click to download covered warrants (100Kb)" on the right hand side. What commands can I use to invoke clicking on this link and initiating the download? And also... (2 Replies)
Discussion started by: figaro
2 Replies

3. Shell Programming and Scripting

Downloading file from internet

Hi, I need to write a script to download a file (say http: //www.mysite.com/myfile.txt) from the internet (please note that the file is on http not ftp). Please let me know if there is any method other than wget. Thanks, Chetan (4 Replies)
Discussion started by: chetanpc
4 Replies

4. Shell Programming and Scripting

File downloading

Hi, I am newbie in Perl/CGI and I need your help to develop a little script to help me to download some files located in a FTP server via HTTP to a disk. I need to authenticate with username/password via a HTTP page and I can choose the files to download from the web page to my disk. Can... (2 Replies)
Discussion started by: imad77
2 Replies

5. UNIX for Dummies Questions & Answers

Unix command used for downloading file from net

Hi, Which command I can use to download a file from website? I tried with wget and lwp-dowload but no gain. Can any one suggest me the good way to dowload? (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

6. Shell Programming and Scripting

File downloading help in perl

Im trying to write a perl code to do the following task. I have a website which is located in a diffirent country. I want to download a file from that site everyday. The file name keeps on changing everyday. say the file name is CTP-latest-5.3.0.37.iso next day it may change to... (0 Replies)
Discussion started by: srijith
0 Replies

7. UNIX for Dummies Questions & Answers

Need help in not fetching a file while file writing operation is not completed

Hi All, We have a Unix program in oracle when we run the program this connects to specified ftp and will get the file into local server. We are facing a problem like when file writing operations is not completed, this program is getting the incomplete file. Could anyone please help me... (2 Replies)
Discussion started by: world.apps
2 Replies

8. Shell Programming and Scripting

Downloading file from mainframe to UNIX

Hi All , I need a help regarding file ftp ing from mainframe to unix.Our source file is mainframe file.I need to download the mainframe file to local unix server through unix script.If anyone can help me how we can do it through unix script ,it will be really helpful.Thanks. (7 Replies)
Discussion started by: STCET22
7 Replies

9. UNIX for Beginners Questions & Answers

File downloading

I saved to disk using lynx, under ls it shows up but no matter what I have done back comes the statment no such file. How do you erase these ls false readings or open what ls shows? (9 Replies)
Discussion started by: Jackbird
9 Replies
SLEEPENH(1)						      General Commands Manual						       SLEEPENH(1)

NAME
sleepenh - an enhanced sleep program. SYNOPSIS
sleepenh [initial-time] sleep-time DESCRIPTION
sleepenh is a program that can be used when there is a need to execute some functions periodically in a shell script. It was not designed to be accurate for a single sleep, but to be accurate in a sequence of consecutive sleeps. After a successful execution, it returns to stdout the timestamp it finished running, that can be used as initial-time to a successive exe- cution of sleepenh. OPTIONS
There are no command line options. Run it without any option to get a brief help and version. ARGUMENTS
sleep-time is a real number in seconds, with microseconds resolution (1 minute, 20 seconds and 123456 microseconds would be 80.123456). initial-time is a real number in seconds, with microseconds resolution. This number is system dependent. In GNU/Linux systems, it is the number of seconds since midnight 1970-01-01 GMT. Do not try to get a good value of initial-time. Use the value supplied by a previous exe- cution of sleepenh. If you don't specify initial-time, it is assumed the current-time. EXIT STATUS
An exit status greater or equal to 10 means failure. Known exit status: 0 Success. 1 Success. There was no need to sleep. (means that initial-time + sleep-time was greater than current-time). 10 Failure. Missing command line arguments. 11 Failure. Did not receive SIGALRM. 12 Failure. Argument is not a number. 13 Failure. System error, could not get current time. USAGE EXAMPLE
Suppose you need to send the char 'A' to the serial port ttyS0 every 4 seconds. This will do that: #!/bin/sh TIMESTAMP=`sleepenh 0` while true; do # send the byte to ttyS0 echo -n "A" > /dev/ttyS0; # just print a nice message on screen echo -n "I sent 'A' to ttyS0, time now is "; sleepenh 0; # wait the required time TIMESTAMP=`sleepenh $TIMESTAMP 4.0`; done HINT
This program can be used to get the current time. Just execute: sleepenh 0 BUGS
It is not accurate for a single sleep. Short sleep-times will also not be accurate. SEE ALSO
date(1), sleep(1). AUTHOR
This manual page was written by Pedro Zorzenon Neto. 2008/04/20 SLEEPENH(1)
All times are GMT -4. The time now is 09:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy