How to sftp fron UNIX to window server using expect?

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to sftp fron UNIX to window server using expect?
# 1  
Old 07-27-2018
How to sftp fron UNIX to window server using expect?

HI
I am using expect to transfer the file from unix system to windows server.
however it is not taking the password.
same I tried without script also but still it is not accepting the password.

when I tried with winscp tool it accepting the password.

I am not sure where I am doing wrong
Code:
 
 #!/usr/bin/expect
spawn sftp root@xx.xx.xx.xx
expect "password:"
send "abcd1234\n"
expect "sftp>"
send "cd /tmp \r"
expect "sftp>"
send "mput t.txt \r"
expect "sftp>"
send "quit \r"

above script working file when tried unit to unix server
# 2  
Old 07-27-2018
Why are you using:
Code:
send "abcd1234\n"

when sending the password (which does not work) instead of using:
Code:
send "cd /tmp \r"

when sending data for the other responses (which does work)?

Note also that you have an unneeded <space> that you are sending before the <carriage-return> character ni your last three sends. The <space> at the end of the cd, mput, and quit commands won't hurt you, but you certainly can't insert an extraneous <space> when sending your password.
# 3  
Old 07-27-2018
Hi Don,

even if I use below command, password is not accepting
Code:
 
 sftp root@xx.xx.xx.xx

but same password is working fine when I am using winscp tool Gui to transfer the file
# 4  
Old 07-27-2018
I didn't say anything about changing:
Code:
spawn sftp root@xx.xx.xx.xx

in your script to:
Code:
sftp root@xx.xx.xx.xx

I suggested changing:
Code:
send "abcd1234\n"

in your script to:
Code:
send "abcd1234\r"

And noted that you could also change:
Code:
send "cd /tmp \r"
expect "sftp>"
send "mput t.txt \r"
expect "sftp>"
send "quit \r"

in your script to:
Code:
send "cd /tmp\r"
expect "sftp>"
send "mput t.txt\r"
expect "sftp>"
send "quit\r"

# 5  
Old 07-27-2018
Hi Don,

ok I got it.
here my concern is why password is accepting when trying with unix server but same working fine when using sftp tool GUI
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to ftp or sftp from workplace to UNIX server?

Hi All, Seeking for your assistance on how to ftp or sftp from workplace to unix server? i tried ftp user/pass but it says "command not found" i tried sftp user@localhost i can't connect. Please advise, Thanks, (1 Reply)
Discussion started by: znesotomayor
1 Replies

2. Shell Programming and Scripting

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

hi guys, i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not and again i have to reverse sftp the files from unix to windows server..... regards, Vasa Saikumar. (13 Replies)
Discussion started by: hemanthsaikumar
13 Replies

3. Shell Programming and Scripting

File Transfer from Window server to UNIX and UNIX to UNIX

Dear All, Can someone help to command or program to transfer the file from windows to Unix server and from one unix server to another Unix server in secure way. I would request no samba client. (4 Replies)
Discussion started by: yadavricky
4 Replies

4. Programming

Calling UNIX command fron FORTRAN

I want to run the unix command in a fortran code echo trim(val_fgsize) | awk '{split($1, a, "/"); print a}'I am trying like this but getting problems s='echo ' // trim(val_fgsize) // '| awk '{split($1, a, "/"); print a}'' call system(s) ---------- Post updated at 05:15 PM ----------... (1 Reply)
Discussion started by: kristinu
1 Replies

5. 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

6. UNIX for Dummies Questions & Answers

SFTP files from Unix to Window Server

I have a requirement, where in we need to SFTP files from the Unix box to the Windows server. Since we are putting files...Where would we place the public/private keys from the Unix servers?? Any default path as such??? How would the sftp happen from Unix to Windows...Please help... ... (1 Reply)
Discussion started by: saggiboy10
1 Replies

7. AIX

Setup Window server to accept AIX SFTP client

To all the expert out there, I have successfully setup a AIX to AIX auto-SFTP with no password requested. Now my aim is to setup a AIX to Window auto-SFTP with no password requested as well. But I faced some problem that I do not know how to solve it. I have followed the setting of AIX's... (8 Replies)
Discussion started by: kwliew999
8 Replies

8. UNIX for Dummies Questions & Answers

scp or sftp to Window server

Dear Unix Gurus, I have a question to confirm before I proceed to script my program. I'm currently running on IBM AIX Ver 5.3. I just like to know if it's compatible to use scp or sftp between AIX and Wintel server? I'm trying to scp or sftp a file from AIX to Window server and I was... (1 Reply)
Discussion started by: lweegp
1 Replies

9. Shell Programming and Scripting

SFTP Shell Script from a Unix server to another

I am facing a typical issue for transfering files through secured FTP (SFTP) for example, i have three different servers a,b & c server A - where data file resides Server B - where Unix shell program resides here(source server) server C - Destination server I wanted to run the shell... (1 Reply)
Discussion started by: kumarm
1 Replies

10. 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
Login or Register to Ask a Question