0

Using a shell script, how can you tell if a screen is running using shell scripts?

For example, using pseudocode:

IF (screen.screenname.running == TRUE)

or something like that.

Mei
  • 4,590
  • 8
  • 45
  • 53
Gray Adams
  • 165
  • 7
  • what's your eventual goal? (I wonder if you are going to say that you want to do something which can be achived instead by screen -d -R or pgrep or ? – stew Feb 17 '12 at 15:56
  • One way to tell the GNU screen is running is to check the `TERM` variable: if the remote server recognizes the `screen` terminal, then this will work. However, this is not a reliable indicator: one could use `vt100` just as well. (In my session, I see `TERM=screen-bce`.) However, I concur with @stew: What are you trying to do? – Mei Feb 17 '12 at 16:42
  • @David me? just help him with his question :) – stew Feb 17 '12 at 16:44
  • @stew: Nah: I'm asking the original poster the same question you did. That's all. – Mei Feb 17 '12 at 17:51

1 Answers1

0
if `screen -ls <screenname> | grep -q "There is a screen on"`; then
    echo "<screenname> is running"
fi
Mark Wagner
  • 18,019
  • 2
  • 32
  • 47