LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-18-2012, 03:15 AM   #1
popecrob
LQ Newbie
 
Registered: Aug 2011
Posts: 21

Rep: Reputation: Disabled
GNU Screen screenshot


Hi there!

I would like to take an actual screenshot as a text file or just a string from a running screen session. I have a poor solution for this, but I want an other performance saver solution.

I'm using many programs in screen sessions with the following command:
Quote:
screen -d -m -S $SCREEN_NAME ./$PROGRAM_TO_RUN
in the .screenrc i've put the following:
Quote:
logfile console.log
The problem is that this line makes all screens to make a separated console.log logfile that is allways writing to disk in every 10 minutes and leaves old screen datas so their size is huge as well. I've 70-80 running screen sessions so its eating relatively a lot of performance, but currently thats the only way for me to look inside a screen session (from php page).

I just want to make a script like this:
Quote:
./getscreencontents $SCREEN_NAME
Wich would give me back the screenshot as a string with a ~25row backward (and if needed 80col width) console size.

Is there any solution for this? Thanks!
 
Old 07-18-2012, 03:18 AM   #2
Roken
Member
 
Registered: Oct 2011
Location: Warrington, UK
Distribution: Arch local, Debian on VPS, several RPIs.
Posts: 300
Blog Entries: 1

Rep: Reputation: 55
Can you set the logfile on a per session basis?

Code:
screen -r $SIM -X logfile /log/destination
 
Old 07-18-2012, 03:30 AM   #3
popecrob
LQ Newbie
 
Registered: Aug 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
Unfortunately no. If I don't missunderstanding your code. The screen isn't reacting to this, even if I'm using -S.
 
Old 07-18-2012, 03:35 AM   #4
Roken
Member
 
Registered: Oct 2011
Location: Warrington, UK
Distribution: Arch local, Debian on VPS, several RPIs.
Posts: 300
Blog Entries: 1

Rep: Reputation: 55
I should have maintained your own naming convention, sorry. I copied and pasted from one of my own scripts. After launching your screen session, it should have been:

Code:
screen -r $SCREEN_NAME -X logfile /log/file
where /log/file is the path to your log file.
 
Old 07-18-2012, 03:46 AM   #5
popecrob
LQ Newbie
 
Registered: Aug 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
It doesn't works for me, not writing any error message when I execute it, and the logfile leaves empty.

What I did:
touch logfile
screen -S test watch -n 5 cat otherfile
screen -r test -X logfile logfile

but nothing happens.
 
Old 07-18-2012, 04:08 AM   #6
Roken
Member
 
Registered: Oct 2011
Location: Warrington, UK
Distribution: Arch local, Debian on VPS, several RPIs.
Posts: 300
Blog Entries: 1

Rep: Reputation: 55
I can see why that wouldn't work - because you are setting the logfile after your command completes. The only way I can think that you could achieve this would be to start each screen with a series of commands (perhaps a small script)

screen -d -m -S $SCREEN_NAME
screen -r $SCREEN_NAME -X logfile /log/file
screen -r $SCREEN_NAME -X log #This is a toggle, so if logging is enabled by default this may disable it. Possibly not needed
screen -r $SCREEN_NAME -X stuff 'command^M'

where "^M" is the escape code (type it with ctrl-v ctrl-m)

Looks messy to me though. Perhaps someone else has a more elegant solution.
 
1 members found this post helpful.
Old 07-18-2012, 04:31 AM   #7
popecrob
LQ Newbie
 
Registered: Aug 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
Thanks, I've now understand it and works. I can turn the logging off after the logfile lookup by
screen -r $SCREEN_NAME -X log off
and remove the logfile
so its temporary and not writing to disk all the time.
But the only problem is, that I can't see the screen history for ~20rows backward, only the new rows after we starts the logging, but its close to the solution.

Last edited by popecrob; 07-18-2012 at 04:33 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I take a text screenshot of a GNU Screen session? FireRaven Linux - Server 3 03-04-2012 08:13 PM
Full screen screen shots -- Screenshot program with hotkeys studpenguin Linux - General 1 03-10-2009 11:58 PM
installing screen(http://www.gnu.org/software/screen/) dreamlemon Solaris / OpenSolaris 5 09-29-2007 03:36 PM
LXer: Gnu-HALO Alpha 0.1 Screenshot Tour LXer Syndicated Linux News 0 06-22-2006 08:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration