Here is the cleaned-up routine I wrote that seems to work under Linux:
#--------------------------------------------------------------------- +---------------------------------------- # Routine: DoSFTPCommands # Description: This routine will take an array of FTP commands and ex +ecute them using SFTP. # # Input: # aCmdList - Array of FTP commands like: # "chdir /data/reports" # "rm weekly_rpt_*.csv" # "put /new/reports/weekly_rpt_2004_07_01.csv" #--------------------------------------------------------------------- +---------------------------------------- sub DoSFTPCommands { my (@aCmdList) = @_; # Put the FTP commands into a file so we can pass the file name to + the SFTP program open (CMD_FILE, ">ftp.cmd"); foreach (@aCmdList) { print CMD_FILE "$_\n"; } close CMD_FILE; # Create a Expect script to run SFTP my $lCmd = '#!/usr/bin/expect spawn sftp -b ftp.cmd MyAccount@ftp.myCompany.com expect -exact " password: " send "myPassword"; interact '; open (EXP_FILE, ">auto.exp"); print EXP_FILE "$lCmd"; close EXP_FILE; # Make the script runable system ("chmod +x auto.exp"); # Run the script system ("./auto.exp"); # Clean up by deleting the two files we created unlink ("ftp.cmd"); unlink ("auto.exp"); } # DoSFTPCommands

In reply to Re^3: SFTP and the Pointy-Haired manager by FatDog
in thread SFTP and the Pointy-Haired manager by FatDog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.