Get directory of running screen session

305 views Asked by At

In general, I have long simulations running on several screen sessions which can get confusing.

Is there a way to get the directory on which one specific screen session is on?

EDIT: I just realized that the easiest thing to do is just to launch the job in the background... Nevertheless, my question still stands.

1

There are 1 answers

0
Thomas Dickey On

You can send a command to screen, e.g., a shell script could do something like this (assuming the session is named MySession):

#!/bin/sh
myfile=$(mktemp)
screen -S MySession sh -c 'pwd >$myfile'
cat $myfile
rm -f $myfile

That seems to work only for the first window opened in a screen session (rather than for the currently active one).