• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: applescript shell script SCP?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: applescript shell script SCP?


  • Subject: Re: applescript shell script SCP?
  • From: Stan Cleveland <email@hidden>
  • Date: Mon, 08 Dec 2008 17:33:46 -0800
  • Thread-topic: applescript shell script SCP?

Title: Re: applescript shell script SCP?
On 12/8/08 4:46 PM, "Mr. Dan Pouliot" wrote:

> My goal is to sftp a file to a server (curl doesn't support sftp).
> The problem is that SCP requires that the password be typed when  
> prompted, after the initial command. I tried throwing the password  
> after a semicolon to make it execute as line 2 of my shell script, but  
> that yeilds error:
> ssh_askpass: exec(/usr/libexex/ssh-askpass): No such file or directory
>
> set theSCPScript to "scp  " & thisPath & "  " & theUsername & "@" &  
> theServer & ":" & thePath & theFileNAME & ";" & thePassword
> do shell script theSCPScript
>
> any ideas or help would be greatlly appreciated!

Dan,

I use the Ruby library "Net-SFTP" via do shell script to do scripted SFTP operations. My experience is with version 1.1.0 of the library, though I understand that version 2.0.1 is available and rumored to be far superior. The code below is for v1.1.0 installed via rubygems. Both localSource and remoteTarget need to be shell-friendly POSIX paths.

Also, if you’re okay with using a GUI-based application, there are scriptable applications that support SFTP such as Interarchy and Cyberduck.

HTH,
Stan C.

property ruby : do shell script "
which ruby" -- get path to active ruby

set localSource to POSIX path of "
Macintosh HD:Users:stanc:Desktop:BkupToExtHD.pdf"
set remoteTarget to "
/VOL/DIR1/DIR2/Backup.pdf"
set {theHost, userID, userPW} to {"
192.168.0.5", "user", "password"}
set {resultText, errText} to sftpFileUpload(localSource, remoteTarget, theHost, userID, userPW)

on sftpFileUpload(localSource, remoteTarget, theHost, userID, userPW)
    set commandText to ("
{|sftp| sftp.put_file(" & quoted form of localSource & ¬
        "
, " & quoted form of remoteTarget & ")}\"")
    try
       set resultText to do shell script (ruby & "
-e \"require 'rubygems' ; " & ¬
            "
require_gem 'net-sftp' ; Net::SFTP.start('" & theHost & ¬
            "
', '" & userID & "', '" & userPW & "') " & commandText)
        set errText to ""
    on error errText number errNum
       set resultText to ""
    end try
   return {resultText, errText}
end sftpFileUpload
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: applescript shell script SCP?
      • From: "Mark J. Reed" <email@hidden>
    • Re: applescript shell script SCP?
      • From: Paul Scott <email@hidden>
References: 
 >applescript shell script SCP? (From: "Mr. Dan Pouliot" <email@hidden>)

  • Prev by Date: Re: specifying "text" language
  • Next by Date: Re: applescript shell script SCP?
  • Previous by thread: applescript shell script SCP?
  • Next by thread: Re: applescript shell script SCP?
  • Index(es):
    • Date
    • Thread