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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:07:02+00:00 2026-05-27T13:07:02+00:00

I am connecting to /bin/bash in ubuntu using: process = Runtime.getRuntime().exec(cmd); Here cmd is

  • 0

I am connecting to “/bin/bash” in ubuntu using:

process = Runtime.getRuntime().exec(cmd);

Here cmd is a String with different commands that i read and write from process.
Now i have come across a situation, where i login to remote machiens using ssh and while reading writing information to ext process, for loggin out from remote machine, i have to send control character like:

CTRL + ] in order to logout the session gracefully and come back to my local machine. Assuming the cmd is a String type, how can i write this CTRL chracter to the process?

  • 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-27T13:07:02+00:00Added an answer on May 27, 2026 at 1:07 pm

    Control-] in ASCII is equivalent to 035 octal. In Java you can represent this as “\035”.

    Writer writer = new OutputStreamWriter(process.getOutputStream());
    writer.write("\035");
    writer.flush();
    

    It is also equivalent to decimal value of 29 so if you can write a byte with a value of 29 then that will work as well.

    OutputStream os = process.getOutputStream();
    os.write(29);
    os.flush();
    

    I assume Control-] has to do with the remote program. You are talking about telnet? However writing “exit\n” will also close the remote bash.

    Writer writer = new OutputStreamWriter(process.getOutputStream());
    writer.write("exit\n");
    writer.flush();
    

    You can also, obviously, close the OutputStream which closes the STDIN of the remote process.

    os.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When connecting to sql server, I have the hardcoded string (local). Is this a
I have someone connecting to my repository using the url (substituted the IP address):
I have a bash script which I wrote that lists out some servers/user names.
I want to start a couple of jobs on different machines using ssh. If
I have a PHP program that uses a Bash script to convert a pdf.
I am trying to write a simple bash script that is listening on a
How to wait in a bash script for several subprocesses spawned from that script
I am using PHP to perform a POST request from a socket. Here is
In bash, I have created a simple daemon to execute commands when my internet
I have downloaded facebook-java-api-3.0.2-bin from http://code.google.com/p/facebook-java-api/ for connecting to face book.I want to use

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.