Sponsored Content
Top Forums Shell Programming and Scripting Unable to do SFTP using expect Post 302945604 by siramitsharma on Monday 1st of June 2015 07:33:06 AM
Old 06-01-2015
Tries the same but still getting prompted for password. Please help
Moderator's Comments:
Mod Comment Please just post replies once. Two duplicates to this post have been removed


---------- Post updated at 05:03 PM ---------- Previous update was at 10:18 AM ----------

Hi,
I have created a function in which I am trying to use the expect command for sftp but it is not working. While copying the same in another script(test.sh) it is working.
CAN YOU PLEASE LET ME KNOW WHY THE SAME IS NOT WORKING IN FUNCTION?

function is as follows
Code:
         function smsiuc_ftp()
        {
                        spawn sftp ftp_dl@10.132.249.50
                        expect "ftp_dl@10.132.249.50's password:"
                        send "database123#\n"
                        expect "sftp>"
                        send "put ZTE_*201505*\n"
                        expect "sftp>"
                        send "bye\n"
                        EOF
                fi
        }


error is as follows:
Code:
 smsiuc_ftp
-bash: spawn: command not found
couldn't read file "ftp_dl@10.132.249.50's password:": no such file or directory
-bash: send: command not found
couldn't read file "sftp>": no such file or directory
-bash: send: command not found
couldn't read file "sftp>": no such file or directory
-bash: send: command not found
-bash: EOF: command not found
cat: output.log: No such file or directory
Null message body; hope that's ok

test.sh script in which sftp is used which is working fine is as follows
Code:
 #!/usr/bin/expect
spawn sftp ftp_dl@10.132.249.50
expect "ftp_dl@10.132.249.50's password:"
send "database123#\n"
expect "sftp>"
send "put ZTE_*201505*\n"
expect "sftp>"
send "bye\n"
exit
~


Last edited by Don Cragun; 06-01-2015 at 01:51 AM.. Reason: Remove duplicate posts.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automating SFTP with Expect

Hello all, I've written an automated SFTP script to work with the Expect command. It recently occurred to me however, that if the client side box does not have the known host entry for the server, it will not work correctly. So I have added an expect for the known host prompt, and that part... (2 Replies)
Discussion started by: sysera
2 Replies

2. Shell Programming and Scripting

expect + cronjob + SFTP

Hi all, i got a really strange problem i wrote a script, when i run this script manually everything works fine but when i make a cronjob for it, with the same user, the EXPECT script will not work. Only the first line will be executed this is the SHell bash script #!/bin/sh; php -q... (2 Replies)
Discussion started by: digitac
2 Replies

3. Shell Programming and Scripting

Help with Expect SFTP script

Hi All, Here is my Expect script, I don't get any error message when I run it. But the file never goes to other system? I also paste the output screen below. When I run the script, the script runs so fast. But when I do it manually, it takes about 10 minutes for the file to transfer. ... (1 Reply)
Discussion started by: samnyc
1 Replies

4. Solaris

Issue with Expect Script for SFTP.

Hi Experts, I am learning expect and wrote the below script for automatic sftp into a server: #!/usr/local/bin/expect -f -d spawn sftp -v test@mumux503 # logs into mumux503 as test user expect "password:" sleep 20 send "test\r"; # sending the password for test... (3 Replies)
Discussion started by: Hari_Ganesh
3 Replies

5. Shell Programming and Scripting

sftp expect timeout problem

hello All, I am doing SFTP using expect. We just change our server from sun solaris 8 to sun solaris 10. The script was working good on sun solaris 8. But it is giving problem on 10. from shell, SFTP is working fine.Please help me. What can be the problem. LIB_sftp_get() { ... (0 Replies)
Discussion started by: mindtee_abhi
0 Replies

6. Shell Programming and Scripting

How to automate sftp without using expect script?

How to automate sftp with out using expect script? My batch file has the password but it is not taking. Please see below. I want to use this sftp connection in a loop for pushing new files in a directory one at a time. Hence I can not use an expect script. bash-2.05$... (5 Replies)
Discussion started by: Tuxidow
5 Replies

7. Shell Programming and Scripting

Using expect to automate sftp

I am trying to use a for loop in my expect cmdFile that I am calling. I want to be able to call either one file name or a series of file names in the working directory (that I won't know the names before hand) and then pass the names to the sftp program. Something like for i in (ls *txt) do (0 Replies)
Discussion started by: vedder191
0 Replies

8. Shell Programming and Scripting

Expect Script for SFTP Upload

I am attempting to utilize an expect script (that is called from a parent bash script) to perform a file transfer over sftp. The script works except I cannot catch timeouts. I need to be able to tell in the parent bash script when the expect script has timed out, or completed successfully. It... (3 Replies)
Discussion started by: thaller
3 Replies

9. Shell Programming and Scripting

Bash Script: Send files to SFTP using Expect

I have to send few gzipped files from local server to SFTP server. My Server Info Distributor ID: Ubuntu Description: Ubuntu 12.04.4 LTS Release: 12.04 Codename: precise Created a bash script and could able to send files to sftp, but i want to send email if transfer is successful. ... (1 Reply)
Discussion started by: krux_rap
1 Replies

10. Shell Programming and Scripting

Problems with expect and sftp in bash

I'm having trouble with some automated sftp pulls. I'm using expect inside bash scripts and spawning SFTP. Some times the expect seems bog down. I have tried to put sleeps in my code to give everything time to work before I move on to next step but I till continue to get issues. For example when... (2 Replies)
Discussion started by: gosteen
2 Replies
All times are GMT -4. The time now is 08:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy