How to know number files transferred


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to know number files transferred
# 1  
Old 08-10-2006
How to know number files transferred

Hi,

I am transferring files from our local server to remote server using FTP command in a shell script.
I am using a the following code,

FTPFILE="ercchk*.txt"
mput $FTPFILE


can any one help me out in calucalating the number of files transfered.
help in this regard is highly appreciated.

regards,
Azaz Ali.
# 2  
Old 08-11-2006
ls -1 ercchk*.txt|wc -l
# 3  
Old 08-11-2006
On my AIX box, ftp output a message from every file tranfered :

Code:
$ ftp localhost
Connected to loopback.
220 KLOGI810 serveur FTP (Version 4.1 Fri Mar 29 22:11:06 CST 2002) prêt.
Name (localhost:user): 
331 Mot de passe requis pour user.
Password:
230 Utilisateur user connecté.
ftp> cd TMP    
250 Exécution de la commande CWD terminée.
ftp> lcd TMP/FTP
Local directory now /home/user/TMP/FTP
ftp> prompt off
Interactive mode off.
ftp> mget F*.DAT
200 Exécution de la commande PORT terminée.
150 Etablissement de la connexion de données pour F0.DAT (0 octets).
226 Transfert terminé.
200 Exécution de la commande PORT terminée.
150 Etablissement de la connexion de données pour F10.DAT (0 octets).
226 Transfert terminé.
200 Exécution de la commande PORT terminée.
150 Etablissement de la connexion de données pour F11.DAT (0 octets).
226 Transfert terminé.
ftp> bye
221 Au revoir.

If you ftp output is similar you can do something like this :

Code:
ftp xxxxxxx >ftp.log 2>&1
echo "#Transfered files : $(grep -c '^226' ftp.log)"


Jean-Pierre.
# 4  
Old 08-12-2006
Hi,

First i would like to thank you for your replies.

My FTP specific code as follows,

PUTHOST=xxxxxx.xxx.xxx.xxx
PUTUSER=xxxxxxxxxx
PUTPASSWD=xxxxxxxx
FTPFILE="xxxxxx*.txt"
ftp -n -v $PUTHOST << EOF
quote USER $PUTUSER
quote PASS $PUTPASSWD
cd xxxxxxx
lcd $xxxx
mput $FTPFILE
quit
EOF


I am a new comer in Unix world so doen't know much about it. Please help me out in this,
ls -1 xxxxxx*.txt|wc -l

the above code gives only the no. of files with xxxxxx*.txt but i don't think so these give the number of files transfered.

Your help in this regard is highly appreciated.

Regards,
Azaz Ali.
# 5  
Old 08-12-2006
its assumed that files of type xxx*.txt are being transferred through the script and thats an indirect way of identifying how many files are going to be transferred with the ls -1 xxx*.txt | wc -l option....

another option has mentioned here to grep from the logs after ftping...

you do use multiple file transfer and why isnt that interactive prompting is not turned off by specifying -i option?
# 6  
Old 08-12-2006
Quote:
Originally Posted by matrixmadhan
its assumed that files of type xxx*.txt are being transferred through the script and thats an indirect way of identifying how many files are going to be transferred with the ls -1 xxx*.txt | wc -l option....

another option has mentioned here to grep from the logs after ftping...

you do use multiple file transfer and why isnt that interactive prompting is not turned off by specifying -i option?

Hi Madan,

First i would like to thank you for your reply.
I don't have much knowledge on both shell scripting as well as on FTP.
I just came to know by seeing the reply that -i option is used to turn off tthe interactive scripting.
Can you please suggest me the code we should be added in the code which i have sent to 1.Log files whenever the script is executed and 2.total number of files transfered.

Regards,
Azaz.
# 7  
Old 08-12-2006
here it is,

ftp -n -i -v <<EOF >logFile
#ftp commands
EOF

you would have the ftp log information in the logFile
and grep for 226 Transfer complete message
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Limit number of files transferred

I've a folder in remote server and it has 50 files. I like to transfer these files by first 10 and next 10 files. I'm using mget command to transfer the files. How to limit the file transfer limit to 10. instead of copying 50 files at a time. Thanks Janarthan (5 Replies)
Discussion started by: Janarthan
5 Replies

2. Shell Programming and Scripting

List files with number to select based on number

Hi experts, I am using KSH and I am need to display file with number in front of file names and user can select it by entering the number. I am trying to use following command to display list with numbers. but I do not know how to capture number and identify what file it is to be used for... (5 Replies)
Discussion started by: mysocks
5 Replies

3. Shell Programming and Scripting

0kb file transferred in FTP process

We are transferring xml files to remote machine through cronjob @every 5 mins and then will move the files to the backup folder is source server. Sometimes the file is transferred as 0kb to destination server, whereas the file in the source backup folder is completely written. There is no error... (6 Replies)
Discussion started by: Bhavi
6 Replies

4. Shell Programming and Scripting

How to check whether files are transferred or not using ftp?

Hi, i want to execute a shell script which transfers files from one server to another using ftp in unix. How can i check whether the ftp is successful or not.(i.e files are transferred to destination server). because if i am checking the return code of ftp, it always shows 0 (denoting ftp is... (5 Replies)
Discussion started by: Little
5 Replies

5. Solaris

How do files transferred via ftp or sftp gets thier permissions at destination?

We have umask defined under /etc/.login as 022. I have my user specific umask defined in /userhome/.login as 002. I understand ftp will not execute anything at destination, it simply transfers files. But it seem to be using 022 as umask for the files transferred. How does ftp knows what umask... (4 Replies)
Discussion started by: kchinnam
4 Replies

6. Shell Programming and Scripting

How to count number of files in directory and write to new file with number of files and their name?

Hi! I just want to count number of files in a directory, and write to new text file, with number of files and their name output should look like this,, assume that below one is a new file created by script Number of files in directory = 25 1. a.txt 2. abc.txt 3. asd.dat... (20 Replies)
Discussion started by: Akshay Hegde
20 Replies

7. Shell Programming and Scripting

Validating the size of file transferred from ftp server to the local system

Validating the size of file transferred from ftp server to the local system. File type: Text file/Flat file Source System: Windows / Unix Systems Target System is always: Unix Mode of Transfer : ASCII We have generic ftp shell script that transfers the files from different ftp servers. ... (2 Replies)
Discussion started by: jpundalik
2 Replies

8. UNIX for Dummies Questions & Answers

How files can be transferred from one system to another securely using Linux?

i need to know how files can be transfered from one system to another securely in linux. (9 Replies)
Discussion started by: bibing
9 Replies

9. Shell Programming and Scripting

How to find whether a file is transferred thro bin or ascii mode?

Hi Gurus, I need to find out, if i have transferred a file from ftp thro bin mode or ascii mode. Say if i have a file called "dec.sh"( u shuld normally transfer thro ascii mode). How can i find out that dec.sh is tranferred from ftp server thro ascii mode or bin mode? Any help would be... (9 Replies)
Discussion started by: Ashok_oct22
9 Replies

10. UNIX for Dummies Questions & Answers

Not file transferred

Hi, I'm having problems when trying to transfer multiple files from remote Pc to AS/400, using command MGET. After successfully connected to remote location and typed MGET FILE1 FILE2 FILE3 (REPLACE; I receive this message: 125 Data connection already open; Transfer starting. 226 Transfer... (3 Replies)
Discussion started by: freddyp
3 Replies
Login or Register to Ask a Question