in reply to Re: connect to FTP server once
in thread connect to FTP server once

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