in reply to connect to FTP server once

You could try it. But that may be a rude (to the server) idea.

In any case, you'll probably run into a timeout somewhere.

If that's not clear, show us code and tell us why you need to avoid re-initiating your connection.
If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.

Replies are listed 'Best First'.
Re^2: connect to FTP server once
by anujkum_perl (Initiate) on Aug 04, 2013 at 17:12 UTC
    thanks for you reply, The problem is that connecting to ftp server taking time around 1 min and I have to upload files as soon as files created in a directory ( a file created in a directory whenever any incident occur and this is a whole day activity). So I thought instead of making connection to ftp server , upload file then close connection, I should establish connection to FTP initially and upload files continously.Below I am sharing a code (I did not share complete script. I only share relevent part of script) ********************************************
    #!/bin/perl use Net::SFTP::Foreign; $sftp = Net::SFTP::Foreign->new($host, user => $user, port => $sport); $sftp->die_on_error("Unable to establish SFTP connection"); print LOGFILE "Connected to $host \n"; ##$appoutdir contain folder name where files resides. ## @ufiles variable contains name of files to be uploaded foreach $ufile (@ufiles) { print LOGFILE "Uploading file " . $ufile . "\n"; my($filename, $directories) = fileparse($ufile); $sftp->put("$appoutdir/$ufile", "$filename") or die "put failed: " . $sftp->error; move("$appoutdir/$filename","$apparchdir/$filename") or die "Moving to application processed directory failed: $!"; }
    **************************************** What parameter/other code could be to get desired functionality. Regards, ANUJ