Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1105037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:34:08+00:00 2026-05-17T01:34:08+00:00

I just wrote a very simple Expect script for wrapping around rsync, but it

  • 0

I just wrote a very simple Expect script for wrapping around rsync, but it seems to be giving me trouble. Basically, I am automating the SSH login prompt called from rsync. I also have to pass arguments through rsync to SSH so it doesn’t do the host key checking. I am well aware of SSH authentication keys and ssh-keygen, but I have good reasons for doing things this way so no lectures on passing passwords on the command-line.

Script


#!/usr/local/bin/expect -f

if {$argc != 5} {
  puts "usage: remoteCopy {remotehost, username, password, localfile, remoteloc}"
  exit 1
}

set remotehost [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set localfile [lindex $argv 3]
set remoteloc [lindex $argv 4]

set timeout -1

spawn rsync -e \"ssh -q -o StrictHostKeyChecking=no\" $localfile $username@$remotehost:$remoteloc
expect "Password"; send "$password\r"

Here is the complete output from the script:

Output


avoelker@localhost  $ ./remoteFileCopy.tcl remotehost remoteuser remotepass ~/localfile /tmp/
spawn rsync -e "ssh -q -o StrictHostKeyChecking=no" /localhost/home/avoelker/localfile remoteuser@remotehost:/tmp/
rsync: Failed to exec "ssh: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(83)
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(434)
send: spawn id exp6 not open
    while executing
"send "$password\r""
    (file "./remoteFileCopy.tcl" line 17)
avoelker@localhost  $

It appears to me that rsync is trying to execute "ssh instead of just ssh, however, copying and pasting the first line of output from Expect’s stdout (rsync -e "ssh -q -o StrictHostKeyChecking=no" /localhost/home/avoelker/localfile remoteuser@remotehost:/tmp/) directly into the shell works perfectly fine, so I know it isn’t a problem with rsync.

When I remove the -e argument entirely from the spawn rsync line, the Expect script executes without errors, but I would have to add in host key checking to the script, which I do not want to do.

Does someone more experienced with Expect/Tcl know what I am doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:34:09+00:00Added an answer on May 17, 2026 at 1:34 am

    Drop your backslashes. The spawn line should just say:

    spawn rsync -e "ssh -q -o StrictHostKeyChecking=no" $localfile $username@$remotehost:$remoteloc
    

    After all, you don’t want rsync to see a command with a quote in it, do you?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wrote a very simple perl tk script to read a huge text
I wrote a script in php. It's very simple, it just multiplies a typed
I'm trying to write a very lightweight build script which will basically just get
I'm probably missing something very simple but I'm new and it's just easier to
I just began learning PHP. I've installed php5 on Linux and wrote very simple
I wrote some very simple code since I'm just starting C++ and I want
I wrote a very simple perl script, and now I want to make it
I wrote a very simple application which just get the current location of the
i wrote a very simple Aspect with Spring AOP. It works, but i have
I just wrote a PHP login script, and what I'm trying to accomplish is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.