Checking the size of a file after FTP

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking the size of a file after FTP
# 1  
Old 03-30-2010
Checking the size of a file after FTP

I am doing a FTP process through which I am copying a file from my local server to Remote server. After this I want to check the size of the file

Below is my program:

quote user $LOGIN
quote pass $PASSWORD
for file in $(find $REMOTEPATH -type f -iname '*.csv'); do
 echo "$file"
 fileSize=`stat -c %s $file`
 echo "$fileSize"
 if [ $fileSize -gt 0 ]; then 
  echo "File exists"
  echo "File does not exist" 

But its not working and throws error

find: /batch/ftpTest: No such file or directory
stat: too few arguments
Try `stat --help' for more information.
We only support non-print format, sorry.
?Invalid command
?Invalid command
?Invalid command
?Invalid command
?Invalid command
?Invalid command
?Invalid command
?Invalid command


Last edited by pludi; 03-30-2010 at 10:07 AM.. Reason: code tags, please...
# 2  
Old 03-30-2010
You are mixing shell script commands into an FTP session. That doesn't work.

If you want more power from FTP, consider using Perl. See my Perl Net::FTP for examples.
# 3  
Old 03-30-2010
Checking the size of a file after FTP

Then can you please tell me how I can do this process?

# 4  
Old 03-30-2010
You mean you want me to write your script?

I gave three examples at that article. In comments people gave other examples. I think that's enough, but maybe not for you.

I'll tell you what: I'm heading out to the gym for a few hours. When I get back, if no one else has been bored enough to do your work for you, I'll lay you out a skeleton of what you need to do.

---------- Post updated at 09:14 AM ---------- Previous update was at 09:03 AM ----------

(My wife says we aren't leaving for 15 minutes)

After logging in etc., you are going to want to do something like

foreach (@files) {
   next if not /.csv$/;
   $localssize=(stat ($file))[7];

# compare, whatever

That's quick off the top of my head; could have mistyped anything - good luck!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Checking for File Size

HI , How can I check if a file exists in a particular folder and it exists it size in greater than 0 kb. Basically I am trying to write a script which will check if a file exists and if exists then it size is greater than 0 bytes (I am not looking for empty files it should have some data... (3 Replies)
Discussion started by: wangkc
3 Replies

2. Red Hat

Checking File size

Hi Team, I am a new bie to unix and want to check a directory for a files with extension *.doc exceeding a specific file size limit,and will give me a buffer ooutput as below I used below command, find . -name \*.doc -size +3k -printf "|%p |%k KB" which resulted as, ./ABC_sw_high.doc ... (1 Reply)
Discussion started by: lisha.ahuja
1 Replies

3. Shell Programming and Scripting

bash: checking file size -solved

Hello I have srv RHEL5, file system UTDM (EMC DiskXtender Unix/Linux File System Manager 3.5 & EMC Centera). it all works under the scheme: have disk is formatted with a file system UTDM, drive open network - NFS, it write data, then migrate the data in the repository - EMC Centera. There are... (0 Replies)
Discussion started by: moskovets
0 Replies

4. UNIX for Dummies Questions & Answers

checking directory size in the text file

Hi All, I am new to unix scripting, please help me in completing this exercise, I have a scenario as follows, 1. i have a text file(snapshot.txt) consisting of directory names, and file size separated by comma as shown below: snapshot.txt data: ... (1 Reply)
Discussion started by: G.K.K
1 Replies

5. Shell Programming and Scripting

Multiple file existence and checking file size

I want to check the files in particular directory are more that 0 Bytes i.e, Non zero byte file. The script should print a msg if all the files in that directory are empty( 0 Byte). (2 Replies)
Discussion started by: lathish
2 Replies

6. UNIX for Dummies Questions & Answers

checking the status of file ftp

Hi, I m new to unix and I need a help in FTp-ing a file. My script is given below ftp -n <<END_SCRIPT open $FTP_HOST user $FTP_USER $FTP_PASSWD lcd $TEMPFOLDER cd $FTP_LOCATION put $1 bye END_SCRIPT exit_status=$? if ; then log "successfully FTPed the file" else... (5 Replies)
Discussion started by: MeeraNair
5 Replies

7. Shell Programming and Scripting

Error checking a file from previous file size

Hi, I'm currently trying to write a script that checks a log file for certain errors. Once checked it then records the filesize in another file. All this is fine, my problem is that the next time I do my error check I only want to check from previously recorded filesize to the end of file. I'm... (2 Replies)
Discussion started by: stuck1
2 Replies

8. Shell Programming and Scripting

checking size of the first line in a log file

Hi My test.log file looks like this: 0 190_GSTV_HUX_003QISCGSK026_error070322_115331917.log 34 190_GSTV_HUX_003QISCGSK026_error070117_151311385.log 12 190_GSTV_HUX_003QISCGSK026_error070117_151230001.log 2 190_GSTV_HUX_003QISCGSK026_error070117_101010001.log 0... (19 Replies)
Discussion started by: kiran1112
19 Replies

9. Shell Programming and Scripting

Help with checking file size

I need to check the size of a log file. If the size is anything but zero, I need to send an email. I'm using this syntax: SIZE=0 VAR1=`wc -c $DIRNAME/$FILENAME1 | awk -F" " '{print $1}' ` echo $VAR1 if then do something such as send an email fi I know that the file is indeed... (15 Replies)
Discussion started by: ssmith001
15 Replies

10. UNIX for Dummies Questions & Answers

Checking file size

What is the best way to check the size of a file? We have a problem with our repository growing to an unmanageable size. If it is greater than 17000000 then I'd like to send a warning to our system administrators. (2 Replies)
Discussion started by: jkuchar747
2 Replies
Login or Register to Ask a Question

Featured Tech Videos