Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > scripting sftp

scripting sftp
Thread Tools
Fresh-Faced Recruit
Join Date: Jan 2003
Status: Offline
Reply With Quote
Mar 10, 2003, 05:28 AM
 
Hi there

I use Terminal to sftp files up to a web server on a regular basis.

Is there a way to script the connection, the entering of a password, cd to the correct directory on the server, and lcd to my local directory?

Do I use AppleScript or a shell script or a combination of the two?

Cheers

BongoMan
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Mar 10, 2003, 02:40 PM
 
Since sftp is based on ssh, you have a couple of options.

1) One item that makes this up is authentication. Falling back to passwords is a last resort for SSH. Instead, do an ssh-keygen on the client, and add that key to the authorized_keys file on the server box. If you want not to prompt for a password, use an empty passphrase in the private key.

2) If you don't want to do that (if the private key could be obtained by someone), you can run ssh-agent, which will cache the passphrase in memory once it has been entered.

Both of these should apply equally to ssh, scp, and sftp, since they're all the same underlying encryption/authentication technology.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Senior User
Join Date: Dec 2002
Location: Portland, OR
Status: Offline
Reply With Quote
Mar 10, 2003, 04:02 PM
 
Can you use scp instead of sftp? SFTP is intended to be used interactive so it is difficult to script actions in it. In general you use a scripting language like "expect" to control an interactive program. Not sure if you can do it with Applescript, my background is Solaris

scp is easier to script because all options are entirely done at the command line. You can just use normal shell scripting to control it. You will still need to use ssh-agent or something to automate the authentication like the previous poster mentioned.
     
Dedicated MacNNer
Join Date: Jan 2003
Location: San Francisco
Status: Offline
Reply With Quote
Mar 17, 2003, 06:27 PM
 
i agree, scp is a lot easier to script. dont bother with scripting sftp unless its absolutley necessary.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:44 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2