2

Why am I trying to do this? Right now I'm trying to make a multi tabbed SSH client for use with a few servers. I have 8 at the moment, soon to be 9. As you can imagine, there are a few redundant tasks one has to do when working with Linux. Connecting to each server to make changes one at a time is a terribly tedious process. That's why I'm trying to make an SSH client that can connect to multiple servers at the same time so I can send a command ONCE to have it affect all servers I own.

How far am I right now? I have a nice UI set up that can connect, log-in, and receive data from the servers. For input, the API requires I specify an inputstream. If I specify System.in as my inputstream, I can then run the program, and have whatever I type into console be broadcast out to the different servers, via the API. enter image description here The problem is that no end user will ever want to work with a separate console to use this program. It will look dinky. So I need some way to take input from the text field to send it through a specified inputstream. That means I'll need an inputstream that never closes unless the program closes. Like System.in. Also, I can't easily redefine the stream once I set it. I searched for an answer yesterday for around 10 hours. Couldn't find anything. If anyone can help, please do. Thank you.

I need an inputstream that works exactly like an outputstream. It stays open even when nothing is being sent through it, but as soon as it gets data, the data is sent automatically to anything that is using it. This API is very strange, but this last inputstream part is the only thing keeping me from finishing up my program. Thank you for your time.

5
  • 2
    Input streams stay open as long as the program that opened them continues to run and does not close them. Your question is very hard to interpret, and would probably benefit from you showing some code. Commented Jan 23, 2013 at 19:22
  • 1
    Here's the code. It's also possible I'm entirely overlooking something. Maybe I don't need the InputStream to be set to anything. Not sure how to get a writable channel with JSCH yet though. Thank you for your quick response. pastebin.com/Y38ErbYz Commented Jan 23, 2013 at 19:39
  • 1
    You want a way to establish multiple SSH connections and then type a single command that gets sent on all sessions, with the output being displayed in one tab per session. This calls for a tool like Puppet or Chef to automate the process. Take a look at those and avoid reinventing the wheel. Commented Jan 23, 2013 at 20:25
  • As to your immediate question, I still don't understand. Each JSCH session has streams for sending and receiving data, and your UI has a textfield in which the user enters a command. Where do you need a stream that "stays open even when nothing is being sent through it"? All streams stay open as long as you want them to, regardless of whether or not something is being sent through them. Commented Jan 23, 2013 at 20:27
  • I've being reading the code that you showed about sessions, in the code there is a class named "SavedLogin", is there a chance that you share that class to see the attributes you wrote so I can make the "ConsoleTab.java" example ? Commented Apr 11, 2013 at 21:18

1 Answer 1

1

JSCH sudo su command "tty" error I was using the API incorrectly. Stupid, yes. I don't want anyone else making the same mistake though. I guess I was following a bad example found somewhere else on the internet. Essentially, you don't even need to set the input stream. You just need to use the output stream that already exists. Write directly to the output stream. Pretty sure I was trying to do this at 3am last night. It was right in front of me the whole time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.