sftp expect timeout problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sftp expect timeout problem
# 1  
Old 12-15-2009
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.

Code:
LIB_sftp_get()
{
   _remote_file="$1"
   _local_file="$2"
   if [ -z "${_remote_file}" ] ; then
      LIB_log_mail_exit "LIB_sftp_put(): no remote file"
   fi

   if [ -z "${_local_file}" ] ; then
      _local_file="${_remote_file}"
   fi

TMP_SFTP_ID="xx.xx.x.x"
TMP_SFTP_USERNAME="xxx"
TMP_SFTP_PASSWORD="xxxxx"
TMP_SFTP_REMOTE_DIR="xxxxxx"
TMP_SFTP_LOCAL_DIR="XXXXXX"
TMP_SFTP_TIMEOUT=-1


expect <<EOF
   set timeout $TMP_SFTP_TIMEOUT
   spawn  sftp $TMP_SFTP_USERNAME@$TMP_SFTP_ID
   expect "password:"
   send "$TMP_SFTP_PASSWORD\r"
   expect "sftp> "
   send "lcd $TMP_SFTP_LOCAL_DIR \r"
   expect "sftp> "
   send "cd $TMP_SFTP_REMOTE_DIR \r"
   expect "sftp> "
   send "get ${_remote_file} ${_local_file} \r"
   expect "sftp> "
   send "bye \r"
EOF

   if [ $? -ne 0 ] ; then
      echo "Failed: LIB_sftp_get()${_remote_file} ${_local_file}"
   fi

   return 0
}

Many thanks in advance.

Regards
Abhishek Kumar

Last edited by pludi; 12-15-2009 at 02:09 PM.. Reason: code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a timeout when using sftp in a script?

Hello guys. I need some help. First of all, sorry about my english, that is not my native languaje. I have a bash script in Solaris with the next lines: And the sftp.sh has this: The problem is that sometimes the sftp takes a long of time. I mean, 2 or 3 hours when it should... (12 Replies)
Discussion started by: giolita25
12 Replies

2. Shell Programming and Scripting

Unable to do SFTP using expect

Hi, I am trying to sftp using expect, but not getting through as it prompt for password is coming Following is the code #/usr/bin/expect > output.log sftp medcdr@10.130.254.50 expect "password:" send "Med@Cdr12\n" expect "sftp>" send "put ZTE_*201505*\r" expect "sftp>" send "bye\r"... (7 Replies)
Discussion started by: siramitsharma
7 Replies

3. Shell Programming and Scripting

Expect timeout

Hello, I'm doing a simple script with expect (a telnet which works without user/pass), and I want to put a condition if timeout happens, then to print a message, but it doesn't work. The script looks like below: #!/usr/bin/expect log_user 0 set timeout 10 spawn telnet IP PORT send... (3 Replies)
Discussion started by: rainbow19
3 Replies

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

5. Shell Programming and Scripting

set Net:SSH:Expect timeout and set it again.

SSHing into a machine can take a few seconds, but after I'm in, the commands return quickly. I was wondering if the timeout setting can be changed once I'm logged into the machine. Does anyone know if this can be set on the fly? The problem here is, if I have to set timeout = 10, it'll take 10... (1 Reply)
Discussion started by: mrwatkin
1 Replies

6. Solaris

SFTP is successful but still shows timeout error

Hi, I am doing sftp from remote server1 to remote server2. This is done through a script. This script was working fine. But if i am tranfer files of 120 MB only some part of the file gets transferred (around 9 MB). Incase i put the same file manually it gets uploaded successfully. Can... (1 Reply)
Discussion started by: subiksha
1 Replies

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

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

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

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