LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-14-2009, 03:33 PM   #1
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Rep: Reputation: 31
simple expect questions


I'm making an rsync script and I'm using expect to enter the ssh password. However, afterward, is there anyway to get the rsync output to go to the terminal? I tried interact, but it waits until I hit enter before continuing with the output if I do that. I read a little about the spawn command and it seems there may be no good way to do this.

I'm using:
spawn rsync <various options>
expect "<password prompt>"
send "<password>"

This just spawns the process and returns immediately to the prompt. I want to see the output!

My ultimate plan is to make one expect script for each rsync command I want to run and then run them all from a bash script (which would be nice enough to wait for each script to complete before running the next one) so that all my backups can be made with one command.

EDIT:

tee doesn't seem to work with the expect spawn command btw

Last edited by davidstvz; 12-14-2009 at 03:46 PM.
 
Old 12-14-2009, 04:05 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
1) expect?? why not use preshared keys?

6.2b) The spawned process will not fork to the background, if that's what you're seeing, then the process muct presumably be completing rapidly for some other reason.
 
Old 12-14-2009, 04:19 PM   #3
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 31
1) maybe I should look into using shared keys instead since I don't need anything more complicated than that (EDIT: in fact I don't; I have it working now using the following instructions: http://www.debian-administration.org/articles/152 )

but it could still be useful to know how to make expect do this

6.2b) The expect script is definitely not returning any output from the spawned rsync command to my terminal (my ssh terminal if that matters). I see the following almost immediately after executing the script:

spawn rsync -r -H -p -o -g -t -v -e ssh --delete /etc user@myserver.com:/spare
user@myserver.com's password:

And that's it. If I put an expect statement:

expect "bytes received"

...after the rsync command then it waits (apparently) until rsync the final line of rsync output before returning.

Are you saying the default behavior should be to show me the output? I'm not seeing it.

Last edited by davidstvz; 12-14-2009 at 04:34 PM.
 
Old 12-14-2009, 07:47 PM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
You should see output. Is there anything that could have turned the output off?
If it is turned off, you can restore it with:
log_user 1

Try also
exp_internal 1
for a debug trace.

As acip_kewpie said, shared keys is much easier, so if you can do that it is preferable.

jlinkels
 
Old 12-15-2009, 11:59 AM   #5
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 31
Thanks, I have got it working with shared keys. I will try to explicitly set log_user 1 next time I try to use expect.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple questions looking for a simple command s3ns4i Linux - Newbie 4 10-21-2008 12:55 PM
Simple Expect problem.. please help :) cdwells Programming 2 07-30-2008 02:49 AM
Simple Questions...Hopfully Simple Answers. caps_phisto Linux - General 3 12-21-2004 12:40 PM
2 Simple Questions The Bag Linux - Newbie 3 10-20-2002 06:36 PM
Questions about what to expect during installation Mango Linux - Software 3 04-14-2002 08:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:35 PM.

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