I'm trying to compile and run a program remotely. However, I'd like to this within a screen and also I'd like to run this using grid engine on another node after I ssh. Currently I have:

ssh me@server screen -R session 'qlogin; cd path; mvn options program'

This basically works, but I get a message saying that I must be connected to a terminal. I read about this and added the -t option to ssh. With that, my command breaks: it seems like I ssh over, screen starts, then doesn't know about the "mvn" command and terminates my session.

I'm wondering why this is happening and how to correctly launch jobs from my local machine, within a screen, on a remote node while using grid engine.


I would add the -L option to screen which turns on your screen log (which defaults to the file name screenlog.0). You then may be able to see what is happening. I would imagine screen is seeing the whole qlogin; cd path; mvn options program as a program to execute, (rather than a set of different commands) failing to execute that and then exiting.

Another alternative is to put the commands being executed into a script:

cd path
mvn options program

Create a screenrc file (say we call it mysessionrc):

# myscreenrc

#Create window 0 with title 'mvn' and run /path/to/myscript.sh
screen -t mvn 0 /path/to/myscript.sh

and then run ssh -t me@server 'screen -R session -c mysessionrc' instead. I've had to do this to get screen working on FreeBSD+ssh+screen combinations.

If that still fails, then I'd add:

zombie kr
verbose on

to the start of your mysessionrc file to make screen prompt about what to do with the running command after it completes k kill or r restart, and verbose will output some info about what screen is getting up to.

  • Thanks but this didn't help me. I can ssh over and start a screen but it doesn't seem like any of the other commands are working and I just get stuck sitting in the new screen
    – akobre01
    Aug 19 '13 at 22:40

My guess would be that when remotely executing a command via SSH, you're not spawning a terminal (pty) to which Screen can attach.

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.