scp script getting timed out with expect


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp script getting timed out with expect
# 1  
Old 04-29-2014
scp script getting timed out with expect

Hi,

I have an expect script where in i am trying to scp a folder but it is getting timed out. Any help will be appreciated. (I don't have the option for sharing keys)

Code:
expect -c 2> /dev/null " spawn scp -r -o NumberOfPasswordPrompts=1 -o StrictHostKeyChecking=no root@10.10.10.10:test_dir /usr/
expect {
             "*?assword:*" { set timeout -1; send test\r\n; exp_continue }
          }
expect eof
"

Also, how to check error code if timeout has occurred?

Last edited by temp_user; 04-29-2014 at 04:14 AM..
# 2  
Old 04-29-2014
Hello temp_user,

Following commands may help in same.

Code:
log_file /tmp/status.log
set timeout 2

By these you can check logs in a file and set the time out too in expect.


Thanks,
R. Singh
# 3  
Old 04-29-2014
Quote:
Originally Posted by temp_user
(I don't have the option for sharing keys)
If your sysadmin doesn't allow you to share keys, they'll be absolutely livid to discover you kludging insecure solutions to automatically login as root with expect.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automated scp using shell & expect

Hi All, I have written a script to automate scp of files. Most of the times it works fine except few cases. I want your help and suggestions to fix these failures. I have used expect & shell to do the automated scp. Below is code $ cat scp.ksh #!/bin/ksh inputfile=$1 fdest_sid=$2... (8 Replies)
Discussion started by: veeresh_15
8 Replies

2. Programming

Expect script returning string following a found expect.

I'm fairly new to scripting so this might not be possible. I am using Expect with Cisco switches and need to capture the string after finding the expect request. For example, when I issue "show version" on a Nexus switch, I'm looking to capture the current firmware version: #show version ... (0 Replies)
Discussion started by: IBGaryA
0 Replies

3. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

4. Shell Programming and Scripting

Using Expect and scp. Not moving directories

An Expect script using scp to copy directories is not moving the subdirectories as wanted. The directory structure is: computerA (user 'test') /home/test/parentDir/subdir1 /home/test/parentDir/subdir2 and I want them copied to computerB (user 'archive') /home/archive/subdir1... (1 Reply)
Discussion started by: nohj ordpl
1 Replies

5. Shell Programming and Scripting

scp not working in expect script

Hi All, I run the scp command in shell prompt without issue, but when on expect script as below: #!/usr/bin/expect spawn scp /var/spool/sms/failed.tar.gz abc@10.10.12.2:/home/abc expect "abc@10.10.12.2's password: " send "abcfef\r" exit 0 It looks not working at all and the... (3 Replies)
Discussion started by: elingtey
3 Replies

6. Shell Programming and Scripting

timed kill within script?

I want to warn everyone, I am not a programmer lol. I'm an IT wanting to get a little insight of programming, and I like to play around so I can learn. Ok, so I'm going to school for IT Security and Forensics. I had a project to write a hack, and I chose to write a shell script to run dd to write... (8 Replies)
Discussion started by: joshbgosh10592
8 Replies

7. Shell Programming and Scripting

How to put scp in background inside expect

Gents, I have a wrapper script passing couple of information to an expect script mainly responsible for spawning scp and providing the password (which is transmitted down from the main script). the main script prepare the transfer to couple of servers, idea being to transfer the files in... (3 Replies)
Discussion started by: luc3004
3 Replies

8. Shell Programming and Scripting

How do I make a timed script

Hello, I would like to make a script, ideally in perl since I am most familair with it, that does the following: automatically starts up at 9 pm, searches through a specified directory for any new files, finds those new files and starts to run them through a pipeline. I have most of it worked... (4 Replies)
Discussion started by: amcrisan
4 Replies

9. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies

10. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies
Login or Register to Ask a Question