Meaningless Drivel is fun!*
The moose likes Linux / UNIX and the fly likes SFTP in unix shell script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "SFTP in unix shell script" Watch "SFTP in unix shell script" New topic

SFTP in unix shell script

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
Hi Everybody,

I know how to use ftp but i dont know how to use sftp.

I tried many times but unsuccessful

I searched in the google but couldn't get good appropriate stuff which is useful for me.

Please can any one help me how to use "sftp" in shell script

can any one provide me sample script

Please help me out!


SCJP 1.4
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020

To use SFTP, you need to be talking to an sftp-enabled server.

I normally use SCP myself, it requires that the receiving server be ssh-enabled and that you have a shell login.

SCP commands are fairly simple:

scp fromfile user@toserver:tofile

user and tofile are optional, as the defaults are your current user id and fromfile's filename, but if you forget the ":", scp will think you're just doing a local copy to a "tofile" named "toserver".

tofile is normally relative to "user"s home directory, but you can also copy to an absolute location on the serve, provided your account has appropriate security privileges.

Customer surveys are for companies who didn't pay proper attention to begin with.
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
NO boss
I need SFTP stuff that too with out interating with user while connecting to the server.
dont worry about ftp server.
I have ftp server :-)

Please help me out if any one knows about how to connect to ftp server using sftp (non-interactive)

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41621
The Ganymed library implements SSH, SCP and SFTP. It's used in client applications such as Cyberduck, so I would imagine it to be rock-solid.

Ping & DNS - my free Android networking tools app
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: SFTP in unix shell script