1748282 Members
3900 Online
108761 Solutions
New Discussion юеВ

counting files with FTP

 
SILVERSTAR
Frequent Advisor

counting files with FTP

Hi there,

I have to get via FTP a number of files from a MPE system, but I do not know how many files are there. It is known that the file name is like BW*.
Using the connection established via FTP is it possible to check how many files are in the folder on the remote machine ?

Thanks
Angelo

5 REPLIES 5
Elmar P. Kolkman
Honored Contributor

Re: counting files with FTP

In the ftp session, disable prompting and do a mget

Syntax would be something like this:
# ftp
>user
>prompt
>binary
>mget BW*
>by
Every problem has at least one solution. Only some solutions are harder to find.
Hoefnix
Honored Contributor

Re: counting files with FTP

Angelo,

if you just want to count number of files via ftp next example will work:

Create an input file(name in.txt) like:
user 'username' password'
ls BW*
quit

then run next command:
ftp -n 'hostname'
This will result in the number of files on the remote host beginning with BW in the home directory of the user.

Regards,

Peter

G. Vrijhoeven
Honored Contributor

Re: counting files with FTP

Hi,

Elmar is right.
his logout must be bye/close.. must be a typo.

Gideon
Marton Ferenc
Advisor

Re: counting files with FTP

You should use another ftp client (eg.: ncftp) which has online monitor function. It displays count of got files/all files, got bytes/All bytes. remaining time, elapsed time, full time etc...
If tcp connection is broken it can build up again and continue from last byte.

So you should find preferred ftp client.
J5000
Dave La Mar
Honored Contributor

Re: counting files with FTP

Angelo -
Just another twist -
ftp to the host, then:
lcd /tmp
ls remote_directory /tmp/remote_file_list

It will prompt you for the copy of the output of ls to be written to your local machine in /tmp/remote_file_list.

From there you can wc or whatever.

Best of luck.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."