I'm kind of new to bash scripting and I'm having trouble figuring out how to accomplish this.

I'm working on a script that is designed to backup and manage a java application that runs within a screen session. The goal is to be able to have multiple instances of the java application running on the different machines and to be able to control them over ssh from the script.

A feature I would like to have is the ability to easily call up the screen session of one of the java instances and display it to the user. So if the screen session is running on Machine A and I want to show it to the user on Machine B, I want to be able to initiate an ssh connection and call that up programmatically.

In short, I want to mimic the following user commands in a bash script:

ssh user@
screen -r ScreenName  #Run from inside of ssh session

How about:

ssh user@host -t screen -r
  • Throws the error: Must be connected to a terminal. – Riley Tench Jul 5 '14 at 1:38
  • 1
    @RileyTench use ssh user@host -t screen -r SCREENAME – Ulrich Dangel Jul 5 '14 at 1:39
  • Wow, that's perfect. For some reason I didn't think that would work, because usually sending a command like that, just executes the command on the remote host and doesn't return anything into the client's terminal. Thank you! – Riley Tench Jul 5 '14 at 1:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.