Check if screen


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check if screen
# 1  
Old 06-23-2011
Check if screen

I have a shell script. I need to make sure when a user executes it, it will be run on a screen in the shell.

If the user starts a screen first and runs the screen, the script should continue running.

If the user did not start a screen and attempted to run the script, the script should automatically start a screen and run continue with the other commands in the script.

Is this possible?
# 2  
Old 06-23-2011
Well, X support usually comes with $DISPLAY. Do you really care if it is a screen, if the called app can make a screen?
Code:
$ xterm -e touch /tmp/X-OK.$$

# 3  
Old 06-23-2011
GNU screen, right? You can check $STY to see if you're inside of a screen session, I think.

If not, you would start a new process, "exec screen myscript" I suppose. ?

edit: like this?

Code:
#!/bin/sh
 
# Go no further unless we're in a screen session!
[ "$STY" ] || exec screen $0
echo you are ok
sleep 3600

# 4  
Old 06-23-2011
I keep forgetting about screens, since modems got past 14400 and IP RAS PPP overtook telnet dialup and slip/slurp. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

O/P same as on screen

#Random Scripts 4 #Desc: clear echo "1. To see all processes currently running on the system" echo "2. To kill any given process" echo "Choose between the two" read x case $x in "1")print `ps aux`;; "2") echo "Choose a process to be killed" read y check=`ps ax | grep... (1 Reply)
Discussion started by: targetshell
1 Replies

2. UNIX for Dummies Questions & Answers

Accidentally made a screen within a screen - how to move it up one level?

I made a screen within a screen. Is there a way to move the inner screen up one level so that it is at the same level as the first screen running from the shell? (2 Replies)
Discussion started by: phpchick
2 Replies

3. Shell Programming and Scripting

Perl code to check date and check files in particular dir

Hi Experts, I am checking how to get day in Perl. If it is “Monday” I need to process…below is the pseudo code. Can you please prove the code for below condition. if (today=="Monday" ) { while (current_time LESS THAN 9:01 AM) ... (1 Reply)
Discussion started by: ajaypatil_am
1 Replies

4. Red Hat

command line tool to disable screen lock and/or screen saver

Hi, I have a simple question : how to disable screen lock and/or sreen saver with command line with RHEL5.4 ? (1 Reply)
Discussion started by: albator1932
1 Replies

5. Solaris

Screen Resolution

Hi all. I have a very peculiar problem in Solaris 10. The output of the m64config -prconf command with regards the Card Adapter is the following. Card possible resolutions: 720x400x85, 640x480x60, 640x480x72, 640x480x75 800x600x56, 800x600x60, 800x600x72, 800x600x75, 1024x768x60 ... (0 Replies)
Discussion started by: lynxman
0 Replies

6. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

7. OS X (Apple)

Virtual screen accessed by Screen Sharing

Hi, I'm trying to create a virtual screen, (maybe xvfb? or any other virtual screen buffer) and be able to use Screen Sharing to connect to it. The setup is that I have a Mac Mini connected to the TV. But when my girlfriend is using Front Row, I can't use Screen Sharing at the same time from... (0 Replies)
Discussion started by: linge
0 Replies

8. Solaris

screen saver

I am using solaris 10 x86, i am trying to create my own sreensavers using the pictures in my folder. pls can someone tell on how to go about this (1 Reply)
Discussion started by: seyiisq
1 Replies

9. UNIX for Dummies Questions & Answers

Help with screen

Hello everyone! I'm trying to figure out how to send commands from one screen to another. For example i wish to send a simple "ls -all" from screen #1 to screen #2, can it be done, and how? :confused: Thank you! (12 Replies)
Discussion started by: Gurth
12 Replies

10. UNIX for Dummies Questions & Answers

Script to check for a file, check for 2hrs. then quit

I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit. Logically, I'm looking for the best way to approach this Thanks for any assistance in advance. Note: I'm using a C shell and... (2 Replies)
Discussion started by: mmarsh
2 Replies
Login or Register to Ask a Question