Register
It is currently Wed Nov 26, 2014 6:37 am

create screen with the script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Mon Dec 20, 2010 9:26 am   

Joined: Mon Nov 08, 2010 10:39 am
Posts: 17
Hello everyone,

I have a little problem. I need to process some code, then create a screen, call a function and detach from the screen. Here is the simplest example (let's use a command ls instead of the function):
Code:
some code here
screen -S test
ls -la
screen -d

Yes, the screen is created but the ls command is not executed as well as any other command/function. The script just hung up on this step. Why?

Could you please someone advise me?


Top
 Profile  
 PostPosted: Tue Dec 21, 2010 8:41 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
Do you really need a screen manager in your code? If you just need the output of the subsequent commands, you can use a log file:
Code:
some code here
ls -la &> test.log


Top
 Profile  
 PostPosted: Sat Dec 25, 2010 4:37 am   

Joined: Mon Nov 08, 2010 10:39 am
Posts: 17
Ok, thank you
I think I will live with it.


Top
 Profile  
 PostPosted: Wed Jan 12, 2011 10:16 am   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
I use screen a lot to launch things in the background that I may want to interact with later. The problem that I've found is that screen won't take multiple arguments for whatever command that you launch. The way that I've worked around this is by writing a separate script with the commands that I want to run in the screen, and calling that.

Code:
## example - one script contains the commands that I want to run in 'screen'

#!/bin/sh
# list-stuff.sh
ls -la

## and we call it from the original script like this

#!/bin/sh
...some code here...
screen -dm /path/to/list-stuff.sh



I hope this helps!
-J


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP