You are not logged in.
hi! im in love with gnu screen, and always have a couple of sessions opened with rtorrent, centerim, and a lot of stuff...
the thing is, that in my current job, i dont have internet connection, so i make myself a script with a cronjob to send me status of my pc via mail to my job's mailbox...
the thing is that i will love to know if there are a way to get a "text-screenshot" of one terminal in a file, here is the script:
#!/bin/sh
tmp=/tmp/status-report-`date +%F-%R`
touch $tmp && chmod 600 $tmp
echo -e "subject: status-report-`date +%F-%R`\n" > $tmp
echo -e "\n -- Uptime -- " >> $tmp
uptime >> $tmp
echo -e "\n -- Temperatures -- " >> $tmp
sensors | grep Core >> $tmp
echo -e "\n -- Disks -- " >> $tmp
df -h >> $tmp
echo -e "\n -- Ram -- " >> $tmp
free -m >> $tmp
echo -e "\n -- Logged Users -- " >> $tmp
who >> $tmp
echo -e "\n -- Processes -- " >> $tmp
top -b -n 1 >> $tmp
/usr/sbin/sendmail -f leandro.chescotta@gmail.com leandro.chescotta@gmail.com < $tmp
rm $tmp
so i want to add to the end, screenshots of some of my gnu screen session's like this:
rtorrent:
*** rTorrent 0.7.9/0.11.9 - aleyscha:????? ***
[View: main]
???? Season 1, 2 and 3
24807.9 / 25503.9 MB Rate: 5.4 / 0.0 KB Uploaded: 9330.7 MB [97%]
Fringe Research Resources
[CLOSED] 0.0 / 949.4 MB Rate: 0.0 / 0.0 KB Uploaded: 0.0 MB
Inactive:
???? Season 1
3485.6 / 4554.8 MB Rate: 2.5 / 7.6 KB Uploaded: 466.5 MB [76%]
[Throttle 8/250 KB] [Rate 8.0/ 7.8 KB] [Port: ?????] [U 5/9] [D 22/60] [H 0/]
centerim:
CENTERIM 4.22.1 UNSENT: 3 msn:o
┌──────────────────────────────────┬─────────────────────────────────────────────┐
│├─ Online ¦ │
││ ├─ [o] mab á~C¦ │
││ ├─ [o] Boky ME¦ │
││ ├─ [o] [c=46]romix(F)- hazme un ME │
││ ├─ [o] [a=41]Juancho[/a] USY │
││ ├─ [d] ' - à¹~QÛ©Û~^Û©à¹~Q BUSY │
││ ├─ [a] Juan.. USY │
││ ├─ [a] JorgeMaxy(Y) USY │
││ └─ [n] Silvina USY │
│└─ Offline USY │
│ ├─ Irina │
¦ ├─ â~W~Oà¹~Kâ~@¢ Marinita á~C¦ │
│ ├─ * NAt´s * {Durmiendo } │
│ ├─ alejandoconmirtalegrand ─────────────────────────────────────────┤
│ ├─ L (*),,,,toca para mi,,,,yo ! 19:50 Correct path or disable screen auto │
└──────────────────────────────────┴─────────────────────────────────────────────┘
F2/m contact menu, F3/s status, F4/g general, ^N/^B next/prev chat, q quit
0 mocp 1* centerim 2 bash 3 bash
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery
Offline
Perhaps you would need something similar to Nethack's dumplogs. They seem to do what you're looking for, but I have no idea of how to implement them into Screen...
Have you Syued today?
Free music for free people! | Earthlings
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery
Offline
heh I just discovered "tee":
bash | tee ~/log
will let you use bash normally, while also logging STDOUT to ~/log. You can use something like tail -n 25 to get a "snapshot" of what was last output to the terminal screen. It doesn't seem to work well with ncurses and stuff though.
Offline
You want screen's "hardcopy" feature. Just hit 'C-a h', and the contents of the current screen will be written to a file called hardcopy.n. You can use it from the command line, for example:
screen -X hardcopy
That will tell the first instance of screen to write a hardcopy file of its current window. The -p option can be used to select a specific window, -r to select a specific instance.
Last edited by skymt (2008-04-23 03:05:37)
Offline
You want screen's "hardcopy" feature. Just hit 'C-a h', and the contents of the current screen will be written to a file called hardcopy.n. You can use it from the command line, for example:
screen -X hardcopy
That will tell the first instance of screen to write a hardcopy file of its current window. The -p option can be used to select a specific window, -r to select a specific instance.
Cool! I didn't know about this feature.
Have you Syued today?
Free music for free people! | Earthlings
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery
Offline
skymt, it's amazing, i think screen was perfect, before i know all the features, and are too much of them
but the thing is that im reading the man and THESE are the fetures i need , i try Ctrl^a+h and the file created is perfect for me to send via mail, but i dont really understand how to use these features in a command from another terminal, i need a command that run in the script, and can pipe the output of that command to the mail i send myself
[aleyscha@aleyscha ~]$ s
There are screens on:
10470.rtorrent (Attached)
20930.h264enc (Attached)
11989.mocp (Attached)
3 Sockets in /tmp/screens/S-aleyscha.
[aleyscha@aleyscha ~]$ screen -X 10470
[aleyscha@aleyscha ~]$
Unknown command: 10470
man page:
-p number_or_name
Preselect a window. This is usefull when you want to reattach
to a specific windor or you want to send a command via the
"-X" option to a specific window. As with screen's select
commant, "-" selects the blank window. As a special case for
reattach, "=" brings up the windowlist on the blank window.
-r [pid.tty.host]
-r sessionowner/[pid.tty.host]
resumes a detached screen session. No other options (except
combinations with -d/-D) may be specified, though an optional
prefix of [pid.]tty.host may be needed to distinguish between
multiple detached screen sessions. The second form is used
to connect to another user's screen session which runs in
multiuser mode. This indicates that screen should look for
sessions in another user's directory. This requires setuid-
root.
-X Send the specified command to a running screen session. You
can use the -d or -r option to tell screen to look only for
attached or detached screen sessions. Note that this command
doesn't work if the session is password protected.
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery
Offline
First off, I would recommend running all your applications in a single screen instance. For example, you could create a screenrc file like this:
sessionname remote
screen -t rtorrent rtorrent [args]
screen -t h264enc h264enc [args]
screen -t mocp mocp [args]
startup_message off
That will start a screen session called "remote", with the programs you listed already running in appropriately titled windows. Save it as "~/.screenrc.remote" and start screen as "screen -c ~/.screenrc.remote".
Then the shell script would look something like this:
for name in rtorrent h264enc mocp ; do
screen -r remote -p $name -X "hardcopy -h hc.$name"
cat hc.$name >> $tmp
rm hc.$name
done
For your current setup, just change line 2 to:
screen -r $name -X hardstatus
Edit: One thing I forgot to mention: if you're going to be leaving the screen session attached, change -r to -d in line 2 as per the documentation for -X.
Last edited by skymt (2008-04-23 19:15:09)
Offline
Thankyou skymt, so nice! the thing is that i like two or more screen sessions with various "sub-sessions", so i open three terminals and "mount" my three screen sessions to that terminals...
but if i use that in the command line the output is:
[aleyscha@aleyscha ~]$ screen -r rtorrent -X hardstatus
There is a screen on:
10470.rtorrent (Attached)
No screen session found.
and tried also:
[aleyscha@aleyscha ~]$ screen -d rtorrent -X "hardcopy -h hc.rtorrent"
There are several suitable screens on:
10470.rtorrent (Attached)
20930.h264enc (Attached)
11989.mocp (Attached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
[aleyscha@aleyscha ~]$
and:
[aleyscha@aleyscha ~]$ screen -r rtorrent -p rtorrent -X "hardcopy -h hc.rtorrent"
There is a screen on:
10470.rtorrent (Attached)
No screen session found.
with no success
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery
Offline
Ah, I found one problem. I thought -X expected a single argument, splitting that into a command and arguments itself. It turns out to be a bit simpler.
$ screen -ls
Your inventory:
16095.rtorrent (Detached)
1 Socket in /tmp/screens/S-mark.
$ screen -r rtorrent -X hardcopy hc.rtorrent
$ ls
hc.rtorrent
$
You should also ignore my advice to include -h. That would include the scrollback buffer, which is obviously not what you want for a full-screen app.
However, despite what the man page says, -d does not make -X send the command to an attached session. Instead, it detaches it as usual, completely ignoring the -X option.
$ screen -ls
Your inventory:
16095.rtorrent (Attached)
1 Socket in /tmp/screens/S-mark.
$ screen -d rtorrent -X hardcopy hc.rtorrent
[16095.rtorrent detached.]
$ ls
$
This is starting to look like a bug. I suppose you could use -d to detach the session, followed by -r … -X … to take the snapshot, but that wouldn't be a very nice solution. Unless I'm missing something, it doesn't seem possible to send a command to an attached session at the moment. I'd suggest reporting it to the screen bug tracker, but it's been overtaken by spambots. My own submission from more than a year ago hasn't been touched.
Offline