SCP (AppleScript Debugger)

Wednesday, March 27, 2002

-- needs: Satimage.osax, SSHPassKey for best results.

property pRemoteHost : "ainaz"
property pRemotePath : "web"
property crcr : return & return
property crcri : return & return & "    "

on escape(theString)
   return "'" & (change "'" into "\\'" in theString) & "'"
end escape

on open fileList
   local localFile, remoteFile, scpList, dialogResult
   set scpList to {}
   set AppleScript's text item delimiters to "/"
   repeat with f in fileList
      set localFile to f's POSIX path
      set remoteFile to last text item of localFile
      activate
      set dialogResult to ¬
         
display dialog "Copy: " & crcri & localFile & crcr & "to “" & pRemotePath & "” on “" & ¬
            
pRemoteHost & "” as:" default answer remoteFile buttons {"Cancel", "Skip", "Copy"} ¬
            
default button 3
      --
cancel is automatically handled
      if button returned of dialogResult is "Copy" then
         set remoteFile to pRemoteHost & ":" & pRemotePath & "/" & text returned of dialogResult
         set scpList to scpList & ¬
            {"
scp " & escape(localFile) & " " & escape(remoteFile)}
      end if
   
end repeat
   
   set AppleScript's text item delimiters to "
" -- linefeed
   do shell script (scpList as string)
   display dialog ((count of scpList) as string) & " file(s) copied." buttons {"Quit"} default button 1
end open
Top | Made with Script Debugger 3.0