Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 [email protected]
screen -r ScreenName  #Run from inside of ssh session
share|improve this question
    
also asked at superuser.com/q/777160/4714 –  glenn jackman Jul 5 '14 at 1:31

1 Answer 1

up vote 2 down vote accepted

How about:

ssh user@host -t screen -r
share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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