Polling an FTP site for a file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Polling an FTP site for a file
# 1  
Old 07-15-2008
Polling an FTP site for a file

Hi,

I'm after a bit of advice for the best way to collect files from an ftp server via a unix process. The main issue here is the frequency, the job needs to check for files every minute or so between 8am and 8pm and pull them down to the box if there is anything there.

Originally the transfer was going to be done via a VPN tunnel direct to a directory on my machine which my batch job would poll, but life is never simple. Unfortunately, that has now fallen through and the files are now being placed on an ftp site instead and I have to pull the files from there as security will not allow a push from there when a file is deposited on it, which also would have made life easier.

My question is, is there a way of opening a connection to the ftp site and keeping it open to poll for a file for that long, or am I just going to have to open and close connections repeatedly throughout the day?

Is there a better way?

Cheers
Paul.
# 2  
Old 07-15-2008
Writing a little here-script that checks every minute in the time window you said might be a proper solution. Keeping the connection open without doing anything might kick you out anyway, depending on how the ftp server is configured.
# 3  
Old 07-15-2008
Thanks for the reply.

That's sort of what I was thinking, a little process to connect up and check and then if found kick of the main shell. Just concerned with opening and closing a connection that often, after all that would mean 720 connections to the FTP during the space of a day from my process alone, let alone with the external companies dropping files on there. I'm just not overly keen on that. Then again I could just be being a little precious about it Smilie
# 4  
Old 07-15-2008
If you have to check it every minute, that is ok, I think. FTP servers usually can stand a lot more of traffic and parallel connections, not sure what hardware, bandwith etc. you are using. I would set it up, let it run and if the admin of the FTP server sees any problems, I guess he will contact you Smilie
# 5  
Old 07-15-2008
Hehehe, many thanks for all the input, very much appreciated Smilie

I've just started coding a little process that once called will loop through all day check the FTP and then if returns a success kick off the main shell. I'm going to run some intensive testing this afternoon and see if the network admins complain about it or not. If not then I am in business Smilie

Many thanks again

Just a thought, could you seen any validity in adding the machine ident, username/password into the .netrc file? That's not going to make a whole heap of difference is it apart from tidy things up a little.
# 6  
Old 07-15-2008
I'd use the .netrc. It makes keeping the password hidden a little easier.
# 7  
Old 07-15-2008
I like expect but the mentioned options are easier. The benefits with expect are that you can build a loggable interface and get a lot of debugging information, notification and control that are impossible otherwise.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To merge files on FTP site before getting them

I have a job that connects to FTP site, rename, get, delete a file and then process it. The renaming is done in consideration of this is one file name into which data is being accumulated many times within 24 hour cycle. This is what happens now: ftp -i $FTPHOST <<-EOF ren... (3 Replies)
Discussion started by: migurus
3 Replies

2. Shell Programming and Scripting

Polling file

HI I need some help on this below one Have summuary file coming on daily basis with list of file names and count ,if the summuary file not exist ,pool it for every 5 mins till it arrives .Once arrived remove first and last line from the file and check all the files in respective director all... (12 Replies)
Discussion started by: mohan705
12 Replies

3. SCO

FTP problem with site exec command

Hello dear Users, I am for the first time in this forum. I come from Germany. Please excuse my bad englisch. My OS is SCO open Server Release 5. I have a problem whith FTP and the command "site exec" if I use the command "ftp> site chmod 777 /tmp/startkpf.sc 200 CHMOD command successful. ... (8 Replies)
Discussion started by: fla5do
8 Replies

4. Shell Programming and Scripting

Polling for existence of file on remote host

I am polling a file on remote host. I have this code that works, but can't explain why it works. while user@remote.no-exist.com 'ls /user/app1/.done'` ] do echo Sleeping for 5 secs sleep 5; done This code works in the way that when the .done file exists on the remote host, the script... (1 Reply)
Discussion started by: starlatch
1 Replies

5. Shell Programming and Scripting

Polling continously for presence of a file

Hi, My os is sun solaris 5.10 and Korn shell scripting. I have a file name like CCNA_EARLY_SWP.w062309 where 062309 is date in mmddyy .This is the value date of the file.(will I need to check continously from 5.00 - 7.00 am daily for this file . If the file has not come at 5 am or 7am... (4 Replies)
Discussion started by: manoj39
4 Replies

6. UNIX for Dummies Questions & Answers

SCP -r from Secure FTP site

Hi all, My problem is simple. I would like to download the contents of a directory on an ftp site. I can access the site through windows, but there are many files and it would be too tedious to click and download each file. Thus, I am trying to use scp -r... (5 Replies)
Discussion started by: cpabrego
5 Replies

7. Solaris

SITE command of FTP not working

Using FTP on Solaris 5.8, I am not able to use the SITE command. It says Invalid command. I am trying to change the permission of the transmitted files to -rw-rw-rw on the destination machine. Any help would be greatly appreciated. (2 Replies)
Discussion started by: gauravsachan
2 Replies

8. UNIX for Dummies Questions & Answers

Site command used in ftp script

Hi everyone, can someone please tell me what can be wrong here? Script: ftp -v -n $FTPSERVER<< EOP >$LOGFILE 2>&1 user $USERID $PASSWD ascii site lrecl=500 site cyl site PRI=600 site SEC=300 lcd $FTPLOCALDIR cd $FTPTARGETDIR put $SOURCEFILE $TARGETFILE quit EOP Output:... (11 Replies)
Discussion started by: swoldering
11 Replies

9. Windows & DOS: Issues & Discussions

mapping FTP site as local drive

I have a small problem, there is one Win98 PC on our network, and I would like to map the FTP server that we have as one of the Win98's machine's local drives. I am by no means a Windows expert, instead my area is *NIX. The webserver is just a regualar webserver, within the LAN. I tried... (18 Replies)
Discussion started by: cerberusofhate
18 Replies

10. UNIX for Dummies Questions & Answers

ftp protocol and quot site chmod 0

i do have a problem with the transaction of pdf-files from a server to another. there was a guy who told me about this command wich i should build in my ftp.put()-method in java. the command called: about quote site chmod 0 filename.. i think its something about filerights but does someone know... (1 Reply)
Discussion started by: calmacroi
1 Replies
Login or Register to Ask a Question