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

  • Home
  • SEARCH
  • 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 6607427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:30:07+00:00 2026-05-25T19:30:07+00:00

I am writing a script to run ssh so as to login a remote

  • 0

I am writing a script to run ssh so as to login a remote host, after all the operation is done, I type exit and log off. But I want the script to continue running and write log on the local host. The script is something like:

#!/usr/bin/expect
spwan ssh qwerty@remote_host

expect {
    "password:" {
        send "123123\r"
    }
}

interact;
send "echo $(date) >> login_history.log\r"

But the last command "send …" always failed with the error message like
"send: spawn id exp4 not open …"

When I log off from the remote host, can the expect script continue to work as it is running on the local host?

  • 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-25T19:30:08+00:00Added an answer on May 25, 2026 at 7:30 pm

    YES, processing can continue after an [interact].

    Short answer: change the last {send …} to {exec date >> login_history.log}

    There are several concepts you’ll want to understand to achieve the control flow you’re after. First, http://www.cotse.com/dlf/man/expect/interact_cmd_desc.htm provides a succinct synopsis and example of intermediate [interact] use.

    Second: why did you see the message “… spawn id … not open …”? Because the spawn id is not open. The script you wrote said, in effect, “interact, then, after interact is over, send a new command to the ssh process.” If you’ve already logged out, then, of course that id for a defunct process is no longer available.

    Third: how do you achieve what you want? I’m unsure what you want. It sounds as though it would be enough for you simply to transform the [send] as I’ve described above. How does that look to you?

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

Sidebar

Related Questions

I am writing a script that installs java on a remote machine. After i
I'm writing a script that is supposed to run around a bunch of servers
I am writing installation script for my program, which is supposed to run on
I'm writing script in remote.ini The script looks like on 1:start:{ server some.irc.server server
I am writing a bash script to run an integration test of a tool
I'm writing a python script that generates html file. Every time I run this
Howdy, I'm writing a batch script that will run on a Windows XP machine.
I am writing a shell script to run under the KornShell (ksh) on AIX.
I am writing a script to automate my iOS building. It will be run
I have an ssh script that uses a local key for login to the

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.