That is pretty much the approach I have taken as well. In my instance, the batch is written dynamically, based on the required process (read from an INI file) and the files found either remotely or locally (based on wildcard searches).
The command that we call looks like: $command = "echo n|\"$psftpDir\\psftp\" $ftpUid\@$ftpAddr -i $ftpKey -pw $ftpPwd -bc -b $commandFile 1>$outputFile 2>$errorFile" The echo answers the caching prompt, the biggest gotcha that I have with the process. From: Mike Malony [mailto:[email protected]] Sent: Tuesday, 28 October 2014 9:22 AM To: Ashley Hoff Cc: Schwartz, Peter W; [email protected] Subject: Re: SFTP I had much the same experience. I've used both PSFTP.exe from Putty and sftp.exe from Cygwin. In both cases I write a batch file and execute the exe via a system call. $RUNSTRING = "$main::sftpbin -b $SFTP_BATCH_FILE $SFTPLOGIN >> $TEMPLOG"; ## which translates to ##'c:\cygwin\bin\sftp -b c:\work\client_batch.txt user@site >> \work\client_user.yyymmdd.log $my_rc = system("$runstring"); For error trapping you need to capture the output and scan it for key words. Though, I think sftp from cygwin give a pretty trustworthy success/fail return code. psftp doesn't. Good luck, Mike On Mon, Oct 27, 2014 at 5:05 PM, Ashley Hoff <[email protected]> wrote: Not sure if you are going to get much more of a response Peter - this mail list seems pretty dead. As far as I know, it's not an easy task to actually get SFTP client functionality in Perl. I've had plenty of issues over the years, that I gave up trying to find a Perl module that will do what I want. In the end, I used PSFTP.exe via a system command call. PSFTP is included with Putty. It can be a bit of a hack, but you can get it to work. Some of the Gotcha's include answering all the interactive prompts (or more to the point, ignore some of them) and capture output, but it's all doable. Cheers Ashley From: [email protected] [mailto:[email protected]] On Behalf Of Schwartz, Peter W Sent: Tuesday, 28 October 2014 2:14 AM To: [email protected] Subject: SFTP I'm trying to locate an SFTP install for Windows (32-bit) but I can't seem to find anything in the PPM for some reason. Does anyone have any recommendations on how to get this for Windows? ________________________________________ Peter W Schwartz | Vice President | IB Tech Market | Investment Bank | J.P. Morgan | Floor 4, 115 S Jefferson Road, Bldg D, Whippany, NJ | T: +1(973) 793-7407 | [email protected] | jpmorgan.com This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
