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 6591065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:22:40+00:00 2026-05-25T17:22:40+00:00

function expect_password { expect -c \ set timeout 90 set env(TERM) spawn $1 expect

  • 0
function expect_password {
    expect -c "\
    set timeout 90
    set env(TERM)
    spawn $1
    expect \"password:\"
    send \"$password\r\"
    expect eof
  "
}

expect_password "scp /home/kit.ho/folder/file1 root@$IP:/usr/bin"

The above expect_password works perfect!

However, I want to transfer multiple files in that directory, so I tried:

expect_password "scp /home/kit.ho/folder/* root@$IP:/usr/bin"

But an error comes up:

/home/kit.ho/folder/*: No such file or directory
Killed by signal 1.

It seems that expect doesn’t recognize *. How can I transfer files in that way?
There is a possible answer using rsync but I can’t use that.

  • 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-25T17:22:41+00:00Added an answer on May 25, 2026 at 5:22 pm

    The manpage of expect says “If program cannot be spawned successfully because exec(2) fails”, so I assume that expect uses exec internally. exec doesn’t call any shell to do wildcard expansion and such magic, which means that your ssh sees the asterisk and can’t handle it. Have you tried to call your shell explicitely like

    expect_password "sh -c \"scp /home/kit.ho/folder/* root@$IP:/usr/bin\""
    

    (maybe you need to omit the single quotes)?

    edit:
    use \” instead of ‘

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

Sidebar

Related Questions

I realized a shell using expect/spawn and send commands to SCP files from a
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
is there a way to find out how many parameters/arguments does the function expect?
I understand and wrote a typical power set function in F# (similar to the
I have a function that expects real numbers (either integers or floats) as its
I'm using a Python API that expects me to pass it a function. However,
$(document).ready(function() { $(span.link).mouseover(function(e){ $(this.children).css(display,inline); }); }); I'm not a javascript expert, but I've cobbled
For Delphi IDE, Is there any tool/expert to know the name of the function
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///

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.