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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:28:56+00:00 2026-05-26T13:28:56+00:00

I need some example Jython, or Java, code to exec an interactive OS shell

  • 0

I need some example Jython, or Java, code to exec an interactive OS shell (/bin/sh). Our development environment is Java on Linux. What I would like to do is provide a means for developers to write Jython scripts, and then drop into a shell, which allows them to inspect the system. The reason I need to exec this from Jython or Java–as opposed to just wrapping all this in a shell script–is that we use Java load some libraries which I need to keep loaded while the interactive shell is running. If the JVM were to terminate before the interactive shell runs, some of our custom hardware would be reset.

I have looked at the Jython subprocess module. However, most of what I have seen will only run and wait on a subrocess to terminate (ie non-interactive). None of the examples show how to the shell can be invoked interactively. The same is true of most of the Java java.lang.Runtime.exec() examples I’ve seen.

  • 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-26T13:28:56+00:00Added an answer on May 26, 2026 at 1:28 pm

    What is wrong with this simple jython code, is that the stdin, stdout do not work as we expect

    import subprocess
    import os          
    subprocess.call([os.environ.get('SHELL', '/bin/sh'), '-i'])
    

    Assuming that we want to spawn the shell on the tty, the following seems to
    give better results:

    import os
    import subprocess
    
    subprocess.call([os.environ.get('SHELL', '/bin/sh') +
        ' -i < /dev/tty > /dev/tty 2>&1'], shell=True)
    

    This will run the shell within another subshell, that replaces the crippled stdin, stdout streams with the active tty.

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

Sidebar

Related Questions

I need to run some example java code. I like using eclipse because it
I've gone through most of the example code and I still need some help.
for example I need some code like: if(need_params('function_name')): print 'function_name($params)'; else print 'function_name()'; endif;
Being new to wxWidgets I need some example code of how to get the
I need some ajax code to assign value to a session for example $_SESSION['verif_code']
I need some help putting together this query in Django. I've simplified the example
I need some help adding conditions to a linq query. Take this small example
I have some .net apps running that I need to monitor for example, then
I need some advice on how to model this simple categorization (?) example: I
I need some Regex help. I've got a series of numbers. For example: 2010

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.