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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:44:13+00:00 2026-06-03T04:44:13+00:00

I need to script/automate an interactive terminal client using Python. The client accepts three

  • 0

I need to script/automate an interactive terminal client using Python. The client accepts three arguments and runs as follows:

>./myclient <arg1> <arg2> <arg3>
Welcome...
blah...
blah..
[user input]
some more blah... blah... for the input entered
blah.. 
blah..
[basically it accepts input and puts the output in the console until the user types 'quit']

Now I need to automate this in Python and the console output saved in a file.

  • 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-06-03T04:44:14+00:00Added an answer on June 3, 2026 at 4:44 am

    You probably want to use pexpect (which is a pure-python version of the venerable expect).

    import pexpect
    proc = pexpect.spawn('./myclient <arg1> <arg2> <arg3>')
    proc.logfile = the_logfile_you_want_to_use
    proc.expect(['the string that tells you that myclient is waiting for input'])
    proc.sendline('line you want to send to myclient')
    proc.expect(['another line you want to wait for'])
    proc.sendline('quit') # for myclient to quit
    proc.expect([pexpect.EOF])
    

    Something like this should be enough to solve your case. pexpect is capable of a lot more though, so read up on the documentation for more advanced use-cases.

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

Sidebar

Related Questions

I need to automate the build/deploy process for my iphone applications from a script.
So here's the scenario. I've got a script that runs some tests. I need
I wrote a python script to automate turning Sweave/LaTeX documents into PDFs. Here's the
I'm writing a script to automate some command line commands in Python. At the
I need to generate multiple databases to SQL, so I need script/program to automatically
I need a script to convert a comma seperated csv file to an excel
I need a script that inserts a number at some point into a file
I need a script that will insert the current date and time in an
I have a PHP script with infinite loop. I need this script running forever.
I have a fileA with a snippet of code, and I need a script

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.