Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 10-02-2003, 09:53 PM   #1
LQ Newbie
Registered: Sep 2002
Posts: 12

Rep: Reputation: 0
Unhappy How to use expect

Please help me with the expect utility.

I need to scp some files to a remote server. I have the script below:

#!/usr/bin/expect -f
set myhost
spawn scp -pr /root/temp/ $myhost:/usr/local/inventory
expect $myhost
send "AbcDeFg\n"

This script works if the password is correct and the server is running. The problem is how to care of the following:
1. When the password is wrong, the program stops and does not timeout because another prompt appears and it is wating user input.
2. When the remote server is down/hanging, the program also hangs and does not timeout.

How can I fix this? Please help.
Old 04-09-2017, 06:23 AM   #2
LQ Newbie
Registered: Apr 2017
Location: Central Texas
Distribution: Ubuntu 14.04
Posts: 3

Rep: Reputation: Disabled
This seems to be an old message and I am new to LQ, but not Linux/UNIX. If you are just interested in "scp", look up setting up your keys for ssh. You can then do:

scp filename

If you have your ssh keys set up, the file should transfer with no trouble. You might also want to look into another utility called 'FileZilla'.
Old 04-09-2017, 08:00 AM   #3
LQ Addict
Registered: Dec 2013
Posts: 5,802

Rep: Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381Reputation: 1381
regnad42, welcome to LQ!
please don't answer 14 year old threads unless you have a very, very good reason for doing so.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect Script coolest Programming 7 02-16-2009 03:59 PM
Expect how to? e-freak Programming 2 09-24-2005 04:49 AM
help with expect neyoung Programming 3 02-09-2004 09:41 PM
Using Expect for Linux rkeng Linux - General 2 08-01-2003 09:01 PM
expect sk8guitar Programming 3 07-29-2003 09:24 PM

All times are GMT -5. The time now is 07:18 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration