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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:14:38+00:00 2026-05-30T21:14:38+00:00

I write the active.ksh script (based on expect) in order to login automatically to

  • 0

I write the active.ksh script (based on expect) in order to login automatically to some Solaris machine and execute the hostname command (login to virtual IP in order to verify which hostname is the active machine – I have two cluster solaris machines )

The problem is with expect; expect sends the password string (pass123) and it misses the Password question, and it still waits for the password.

So actually the password (pass123) was entered after password question. On most cases the expect script works fine but sometimes it missed the password.

EXAMPLE OF THE PROBLEM

 ./active.ksh
 spawn ssh 10.10.18.61
 sh: /usr/local/bin/stty: not found
 This computer system, including all related equipment, networks and network devices      (specifically including Internet access),is provided only for authorized uss
 Password:        * my remark - pass123 string was missed the Password Question        pass123
 Password: 

THE SCRIPT

  more active.ksh  



  #!/bin/ksh

  VIP_ADDRESS=10.10.18.61


  expect_for_verify_which_active_machine=`cat << EOF
  set timeout -1
  spawn  ssh   $VIP_ADDRESS 
  expect {
  ")?"   { send "yes\r"  ; exp_continue  }
  Password:  {send "pass123\r"}
  }
  expect >  {send "hostname\r"}
  expect >    {send exit\r}
  expect eof
  EOF`


  expect -c  "$expect_for_verify_which_active_machine"

EXAMPLE OF RIGHT RESULTS

  ./active.ksh 
  [Friday, February 24, 2012  2:32:06 PM IST] INFO Verify which is active SMU machine 
  spawn ssh 10.10.18.61
  sh: /usr/local/bin/stty: not found
  This computer system, including all related equipment, networks and network devices       (specifically including Internet access),is provided only for authorized uss
  yes
  Password: 
  Last login: Fri Feb 24 14:32:06 2012 from smu1a
  This computer system, including all related equipment, networks and network devices       (specifically including Internet access),is provided only for authorized uss
  solaris1:/ ROOT > hostname
  solaris1
  solaris1:/ ROOT > exit

  logout
  Connection to 10.10.18.61  closed.
  • 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-30T21:14:39+00:00Added an answer on May 30, 2026 at 9:14 pm

    Maybe it will be easier to script this process using empty. It’s a small utility similar to expect but more convenient in some cases. You can use it to just “type text into an application”, and you can ignore the application’s prompts (though you don’t have to). Logging to a remote machine and executing hostname could look like this:

    ./empty -f -L templog ssh 10.10.18.61 hostname
    echo YOUR_SECRET_PASSWORD | ./empty -s -c
    cat templog
    

    The first one starts your command in the background. The other one sends it data (your password) from stdin. The whole session (including passwords!) is logged to file templog where you will find also the result of hostname. There are also mechanisms for finer-grained control, but they may be a bit harder to set up.

    As some people already pointed out, ssh keys are the way to go, this is just an ugly and unsafe workaround (it’s risky due to shell history being preserved, users being able to see your password in ps results, and in my example the password is additionally saved in the templog file etc).

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

Sidebar

Related Questions

I need to write a OS X login hook script that is aware of
I am attempting to write an application that automatically changes the proxy server based
I'd like to write a .net program to update active directory data in an
I'm trying to write a registration using devise and active merchant. The form is
I would like to write a module that provides active record like functionality on
I am trying to write a Python script that will access and modify the
I write an application based on an already existing database (postgreSQL) using JPA and
I'm planning to write a 3D FPS game, based on WebGL. Should I use
I am running Active Perl 5.14 on Windows 7. I am trying to write
Is it somehow possible to write active-x component on Java? Any library, tutorial and

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.