Visit Our UNIX and Linux User Community

Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)
# 8  
Old 07-30-2014
Originally Posted by hemanthsaikumar
But i had a requirement of writing the script for SFTP... is it possible..??i want to run the script as its my requirement
Whoever specified that requirement needs to learn how to specify REQUIREMENTS and not solutions.

Your REQUIREMENT is to move files from server to server.

SFTP is just ONE possible solution. One that's a lot harder to implement than scp or rsync.
# 9  
Old 07-30-2014
Okay.Then u have written some code that is fine just give file name after get that it will pull the file from windows. ..

---------- Post updated at 05:52 PM ---------- Previous update was at 05:51 PM ----------

Before that try to check u are able to login into mentioned remote directory
# 10  
Old 07-30-2014
i have to get the same to my unix server of local path how to do that after get command do i need to specify anthing..?
# 11  
Old 07-30-2014
There are ways to do it,
If you company got money, there is something called IP Switch - File_transfer, WS_FTP Server.

If you want to go freebee, install cygwin on your windows machine (install ssh, crontab).
Do a ssh-key exchange, write a script and you are all done.
# 12  
Old 07-30-2014
Okay specify remote file name next to that it will download the file from your remote server i.e from your windows server
# 13  
Old 07-30-2014
As you want to run the script interactionless, you have to know the remotedir/filename, so it would be pointless to check its existence first - it's there or not. Why not get it and check success/failure?
sftp  ${remoteuser}@${host} <<EOF 2>&1 >/dev/null | awk 'NR>1 {exit 1}'
get ${remotedir}/${filename}
echo $?

The awk piece will make sure the right exit code will be issued.

EDIT: The sftp ":" form will even simplify that:
sftp ${remoteuser}@${host}:${remotedir}/${filename} && echo "found" || echo "missing"

Last edited by RudiC; 07-30-2014 at 05:38 PM..
# 14  
Old 07-31-2014
Very old ftp ran on tcp ports 21, 20 and high ports unsecured only by a password sent in the clear. It had an arcane command set, somewhat like a severly truncated shell.

ssh runs on a different tcp port/server, 22 by default, is secure and can be set up with PPK trust so no password is needed, which supports secure scripts. It is a secure tcp socket with apps that allow remote shell, tcp tunnels or file copy.

sftp is a wrapper for ssh that speaks ftp. It is for people who want to keep using an ftp script already written, not you.

scp/winscp is another wrapper for ssh, more like the rcp and cp commands. For Push you just:
scp path_here user@there:path_there

or for Pull:
scp user@there:path_there path_here

Last edited by DGPickett; 07-31-2014 at 04:25 PM..

Previous Thread | Next Thread
Test Your Knowledge in Computers #372
Difficulty: Easy
The Ericsson implementation of Erlang uses DREAM bytecodes.
True or False?

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Passwordless sftp connection from UNIX to windows server

HI , I am trying to make a passwordless sftp connection from a unix server to windows server I have used a existing script which is like this cd /home150/adm/.ssh/ ssh-agent /usr/bin/ksh <<EOF ssh-add IDBNEWKEY ssh-add -l sftp cd /home/IDBUSER/Share/IDB/ rm ${FILE}... (0 Replies)
Discussion started by: Jcpratap
0 Replies

2. IP Networking

How to transfer files from UNIX server to windows machine or vice versa using ftp or sftp commands?

hi, i want to write a shell script code which transfers files from a directory in unix server to a directory in a windows machine.. can any1 give me a sample code which uses ftp or sftp command.. thanks very much, (3 Replies)
Discussion started by: Little
3 Replies

3. Shell Programming and Scripting

Sftp some files from windows server to UNIX server

hi i need to transfer some files from windows server to unix server using SFTP. but before transferring the files, i need to check the existence of a particular file in the remote directory (say r_dir1). if the file is present, then SFTP all the files. after SFTPing the files from the remote... (1 Reply)
Discussion started by: vinit raj
1 Replies

4. Shell Programming and Scripting

Unix shell script to Copy files from one Windows server to another Windows server.

Can anybody please help me on how to code for the below requirement: I need to write a shell script (on different unix server) to copy files from multiple folders (ex. BRN-000001) from one windows server (\\boldls-mwe-dev4)to a different windows server(\\ This shell... (4 Replies)
Discussion started by: SravsJaya
4 Replies

5. Shell Programming and Scripting

Error copying files from Unix (Solaris10) to Windows Server 2003 using scp/sftp

Hi, I have generated a Public/Private Key Pair in Solaris Unix (source) server and deployed the Public key in Windows 2003(target) server .ssh directory of user profile. When i try to connect(ssh, scp, sftp) from Unix, i'm getting below error message. Sun_SSH_1.1, SSH protocols 1.5/2.0,... (0 Replies)
Discussion started by: ajaykumarb
0 Replies

6. Shell Programming and Scripting

SFTP latest file from Windows server to Unix host

Hi All, I am SFTP ing file from Windows server (Sydney) to Unix host in London (both servers are on different timezones). It appears the upstream (Windows server team) does not do a file housekeeping activity and henceforth there are multiple files i.e. each week the script is scheduled to run... (1 Reply)
Discussion started by: vigdmab
1 Replies

7. Shell Programming and Scripting

sftp Connection from Unix to Windows 2003 server using Passphrase

Hi All, I am trying to connect from Unix machine to Windows 2003 server using passphrase method. It is connecting to the server and the connection is immediately closing. Below is the stack trace. Can anyone let me know what wrong with it? cwadmin@iut1wps1:/home/cwadmin> ssh username@targetip... (1 Reply)
Discussion started by: vijayin
1 Replies

8. Shell Programming and Scripting

SFTP failure from unix to windows server

Hi, I am having unix server SUNW,Sun-Fire-V245. remote windows server details: Microsoft Windows In my script i am sftp'ing files to the windows server through sftp command. But the problem i am facing is, some files are successfully sftp'd to windows server and for some files sftp is... (0 Replies)
Discussion started by: syamkp
0 Replies

9. Shell Programming and Scripting

SFTP from windows E:/ to unix server

Hello All :), I am making a script in the ksh to Secure FTP a set of files from the E:/ drive in windows a computer to a unix server. Had it been in the unix directory, I could have used the expect utility to use the non-interactive mode for sftp, #!/usr/local/bin/expect #!/bin/ksh ... (12 Replies)
Discussion started by: pranavagarwal
12 Replies

10. Shell Programming and Scripting

SFTP from UNIX (AIX) to Windows 2000 server

Hi all, I have to sftp a file (put) from AIX server to Windows 2000 server. The question is Windows 200 server that i am using doesnt have any SFTP server , if so i know we need to install one. The question here is for writing a sftp script that as to run everyday as part of cron job we... (0 Replies)
Discussion started by: reddymails
0 Replies

Featured Tech Videos