Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
the beauty of screen+script+emerge
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
apokalyptik
n00b
n00b


Joined: 18 Jun 2002
Posts: 62

PostPosted: Mon Sep 09, 2002 3:46 pm    Post subject: the beauty of screen+script+emerge Reply with quote

Screen is a useful tool for running programs in a detatched terminal. along with other benefits a screens' processes re not killed when the screen is detached (unlike a telnet/ssh session)

Script is a tool to log everything coming into or going out of your terminal to a file for later review

If you dont know what emerge does then you're in the wrong place!
Code:

# su
Password: XXXXXXXX
# screen
# script
Script started, file is typescript
# emerge dcron & screen -d
# exit
logout
# exit
logout

{ later, when you have time }
Code:

# su
Password: XXXXXXXX
# screen -r
# { enter }
[1]+  Done                    emerge dcron
# exit
Script done, file is typescript
# exit
[screen is terminating]
# cat typescript

This block of code is our script-ed log file (very cool)
Code:

# emerge dcron & screen -d
[1] 30647
[24614.pts-0.www detached.]

# Calculating dependencies ...done!
>>> emerge sys-apps/dcron-2.7-r9 to /
>>> md5 ;-) dcron27.tgz
>>> Unpacking source...
>>> Unpacking dcron27.tgz
patching file Makefile
patching file database.c
>>> Source unpacked.
fgrep -h Prototype main.c subs.c database.c job.c crontab.c subs.c >protos.h
gcc -march=i686 -O3 -pipe -Wall -Wstrict-prototypes   -c -o main.o main.c
gcc -march=i686 -O3 -pipe -Wall -Wstrict-prototypes   -c -o subs.o subs.c
subs.c: In function `slog':
subs.c:82: warning: `%y' yields only last 2 digits of year
gcc -march=i686 -O3 -pipe -Wall -Wstrict-prototypes   -c -o database.o database.c
gcc -march=i686 -O3 -pipe -Wall -Wstrict-prototypes   -c -o job.o job.c
gcc -march=i686 -O3 -pipe -Wall -Wstrict-prototypes -o crond main.o subs.o database.o job.o
gcc -march=i686 -O3 -pipe -Wall -Wstrict-prototypes   -c -o crontab.o crontab.c
gcc -march=i686 -O3 -pipe -Wall -Wstrict-prototypes -o crontab crontab.o subs.o

>>> Install dcron-2.7-r9 into /var/tmp/portage/dcron-2.7-r9/image/ category sys-apps
strip:
/var/tmp/portage/dcron-2.7-r9/image/usr/sbin/crond
/var/tmp/portage/dcron-2.7-r9/image/usr/bin/crontab
>>> Completed installing into /var/tmp/portage/dcron-2.7-r9/image/

>>> Merging sys-apps/dcron-2.7-r9 to /
--- /var/
--- /var/spool/
--- /var/spool/cron/
--- /var/spool/cron/crontabs/
--- /usr/
--- /usr/sbin/
>>> /usr/sbin/crond
--- /usr/bin/
>>> /usr/bin/crontab
--- /usr/share/
--- /usr/share/doc/
--- /usr/share/doc/dcron-2.7-r9/
>>> /usr/share/doc/dcron-2.7-r9/CHANGELOG.gz
>>> /usr/share/doc/dcron-2.7-r9/README.gz
>>> /usr/share/doc/dcron-2.7-r9/crontab.gz
--- /usr/share/man/
--- /usr/share/man/man1/
>>> /usr/share/man/man1/crontab.1.gz
--- /usr/share/man/man8/
>>> /usr/share/man/man8/crond.8.gz
--- /etc/
--- /etc/init.d/
--- /etc/init.d/dcron
-o- /etc/crontab

>>> Safely unmerging already-installed instance...
--- !mtime obj /usr/share/man/man8/crond.8.gz
--- !mtime obj /usr/share/man/man1/crontab.1.gz
--- !mtime obj /usr/share/doc/dcron-2.7-r9/crontab.gz
--- !mtime obj /usr/share/doc/dcron-2.7-r9/README.gz
--- !mtime obj /usr/share/doc/dcron-2.7-r9/CHANGELOG.gz
--- !mtime obj /usr/sbin/crond
--- !mtime obj /usr/bin/crontab
--- !empty dir /var/spool/cron/crontabs
--- !empty dir /var/spool/cron
--- !empty dir /var/spool
--- !empty dir /var
--- !empty dir /usr/share/man/man8
--- !empty dir /usr/share/man/man1
--- !empty dir /usr/share/man
--- !empty dir /usr/share/doc/dcron-2.7-r9
--- !empty dir /usr/share/doc
--- !empty dir /usr/share
--- !empty dir /usr/sbin
--- !empty dir /usr/bin
--- !empty dir /usr
--- !empty dir /etc/init.d
--- !empty dir /etc
>>> original instance of package unmerged safely.

 * To activate /etc/cron.{hourly|daily|weekly|montly} please run:
 * crontab /etc/crontab

 * !!! That will replace root's current crontab !!!

>>> Regenerating /etc/ld.so.cache...
>>> sys-apps/dcron-2.7-r9 merged.
>>> Recording sys-apps/dcron in "world" favorites file...

 * GNU info directory index is up-to-date.
 * IMPORTANT: 1 config files in /etc need updating.
 * Type emerge --help config to learn how to update config files.


[1]+  Done                    emerge dcron
# exit

Script done on Mon Sep  9 08:37:54 2002

Code:

# rm typescript
# exit
logout
# exit
logout

In this way you can build parts of your system while not being attached to it, and review configuration changes, and advisories at the end of each emerge... I also recommend scripting for any emerge which will compile dependencies, so that you can look at package bulletins later (after text is done flying by at a million miles per hour)
_________________
http://www.apokalyptik.com/
Back to top
View user's profile Send private message
Crash1976M
n00b
n00b


Joined: 30 Aug 2002
Posts: 65

PostPosted: Mon Oct 07, 2002 2:05 am    Post subject: Reply with quote

i knew screen (and some of its features) but i didn't know script. - it's really a fine tool.
but, is there anywhere a docu of screen in a real readable format, because i am not really happy with this man page things.

Tank you

Michael
Back to top
View user's profile Send private message
UnderScore
n00b
n00b


Joined: 14 Jul 2002
Posts: 25
Location: Long Island, NY, USA

PostPosted: Sat Oct 12, 2002 5:24 am    Post subject: Reply with quote

For more help & info on screen go here http://www.math.fu-berlin.de/~guckes/screen/
Back to top
View user's profile Send private message
Crash1976M
n00b
n00b


Joined: 30 Aug 2002
Posts: 65

PostPosted: Sat Oct 12, 2002 10:40 am    Post subject: Reply with quote

Thank you

I forgot Sven - i saw him last year on the linux days in Austria.

bye

Mike
Back to top
View user's profile Send private message
corporate_gadfly
n00b
n00b


Joined: 21 Sep 2002
Posts: 29

PostPosted: Thu Oct 17, 2002 1:41 pm    Post subject: screen already has its own logging Reply with quote

I don't think you need script, since screen already has its own logging. There's at least 2 ways on how you can enable logging.

1. By starting screen with:
Code:
screen -L

2. or, once inside screen you can go to the "C-a :" prompt and type in
Code:
log on


thereby eliminating the need to use script. :)
Back to top
View user's profile Send private message
bdunn
n00b
n00b


Joined: 18 Jun 2002
Posts: 10
Location: Grand Prairie, TX

PostPosted: Sat Nov 09, 2002 11:27 pm    Post subject: Reply with quote

That seems like a lot more trouble than something like this:

Code:
nohup emerge mozilla &


(Disconnect from SSH or whatever)

Go back later and you'll find a nohup.out file containing everything that happens (and with mozilla, that's going to be a lot!)

Is there something about screen/script other than the ability to switch to many different virtual screens with screen?
Back to top
View user's profile Send private message
fleed
l33t
l33t


Joined: 28 Aug 2002
Posts: 756
Location: London

PostPosted: Sun Nov 10, 2002 12:07 am    Post subject: Reply with quote

I usually just use the nohup method too. I think screen+script could be more useful in other cases, not particularly when emerging.
Back to top
View user's profile Send private message
rks1789
n00b
n00b


Joined: 26 Sep 2002
Posts: 56

PostPosted: Wed Jun 25, 2003 2:22 pm    Post subject: Reply with quote

I think the real power in using screen is that you can detatch from it, and re-attatch later and be exactly where you left off.

This can be usefull if you have an unstable connection, or if you just want to stop working in 1 place, and start again in another.

After you start screen (and do what you want), ^a^d to detatch.

Then when you want to reconnect do

screen -r

If you were disconnected without detatching you can do

screen -rd

Which will detatch the screen process and then attatch to it. If you omit the -r/-d options then you will create a NEW screen process.

Rich
Back to top
View user's profile Send private message
snakü
n00b
n00b


Joined: 28 Jun 2003
Posts: 23

PostPosted: Sat Jun 28, 2003 4:25 am    Post subject: Reply with quote

Screen is handy if you ssh or telnet into a machine, want to view a lot of different things, but don't want all kinds of terminal windows. Sort of like the console's virtual terminals, but in xterm or PuTTY windows. In addition, you can split the screen so you can see several of those windows at once, something that the above link does not discuss.

Inside screen...

Control-A Control-C
(Create new "window" and switch to it.)
Control-A S
(Create a new "region.")
Control-A TAB
(Switch to new/next "region")
Control-A "
(Pull up a list of open "windows" to select from.)
Control-A A
mywindow

(Give current window a name.)

You can now select your original window to view in the new "region." Of course, multiple regions can be created and regions can be resized (man screen for the resize command).

As that link mentions, if you're working on a couple of different workstations, or for some reason want others to be able to monitor your session, you can point multiple terminals to the same screen session. Be aware that each instance can manipulate the screen session. See the man page for permissions issues between users.

Assuming you have a screen session running in another terminal...
Code:

snake@snaku450#screen -list
There is a screen on:
            14656.pts-0.snaku450     (Attached)
1 Socket in /var/run/screen/S-snake.

(Find it.)
Code:

snake@snaku450#screen -x pts-0

(Attach in multi-display mode)

Be sure to detach (Control-A d) rather than "exit," if you want to close one terminal, but not the entire session.

See the man page for all sorts of other features.
Back to top
View user's profile Send private message
meowsqueak
Veteran
Veteran


Joined: 26 Aug 2003
Posts: 1549
Location: New Zealand

PostPosted: Thu Aug 28, 2003 1:05 am    Post subject: Screen can multiplex Reply with quote

Screen has a really nice feature I use a lot:

You can start up a process (like irssi) using the -d -m flags and automatically detach, and give it a symbolic name with -S. For example, to start up irssi in a screen, do the following:

$ screen -d -m -S irc irssi

You can now refer to this detached screen as 'irc'. Now for the fun bit:

$ screen -x irc

This will attach you to the screen session called 'irc' as you would expect. Now, travel 100kms to work, ssh to your box and type:

$ screen -x irc

Voila! You've reattached to your screen session WITHOUT detaching the one you started first at home. You are essentially multiplexing the session to several TTYs. You can do this many times, even on the same box. It even makes for a decent practical joke if you set it up right :)
Back to top
View user's profile Send private message
MooktaKiNG
Guru
Guru


Joined: 11 Nov 2002
Posts: 326
Location: London, UK

PostPosted: Thu Aug 28, 2003 12:16 pm    Post subject: Reply with quote

Screen is great when you want to download things, have multiple bittorrent downloads, run emerge, and then run mutt all in one ssh window :D

Its a fantastic tool, i fell in love with it ever since i saw it.

I usually make a small script for each program i want to run in screen. eg:

This is the script i use for running bittorrent:
Code:
#!/bin/bash
## Just a small script for me to run bittorrent ##
cd ~/Downloads && \
screen btdownloadcurses.py --max_upload_rate 10 --responsefile $*
screen -list


That runs bitorrent in a new screen window and then i just do: CTRL+A CTRL+D and then detatch from it. Later i do:
Code:
screen ls


Which will list all the windows i have running.
gives something like this:
Quote:
There are screens on:
22779.pts-1.mooktaking (Detached)
2 Sockets in /var/run/screen/S-mma.


And then reatatch using:
Code:
screen -R 22779.pts-1.mooktaking


You can also use names to create new window and use that name to reattact to it again:
Code:
screen -R download

reattach:
Code:
screen -R download


Its a fantastic tool.
_________________
http://www.mooktakim.com
Athlon XP 2001, Giga-Byte GA-7VRXP MB, 640Mb DDR RAM 333MHz, MSI Geforce 4800SE 128Mb DDR, 40x12x48 Liteon CDRW drive, Flower Cooler, ADSL Router
Back to top
View user's profile Send private message
turtlendog
Tux's lil' helper
Tux's lil' helper


Joined: 31 Jan 2004
Posts: 107
Location: East AZ

PostPosted: Sat Jan 31, 2004 5:53 am    Post subject: Syslog h&ack Reply with quote

Thanks for the good tips!

Here's one I havent' seen in this thread.

Edit your /etc/syslog.conf to include:

Code:
*.*          /dev/tty12


Then you can see all the latest syslog messages by hitting alt+F12.

I picked this up from a Mandrake install where I specified "Paranoid" for the system security level.
Back to top
View user's profile Send private message
Terminal Insanity
n00b
n00b


Joined: 20 Aug 2003
Posts: 51

PostPosted: Mon Mar 29, 2004 3:41 am    Post subject: Reply with quote

I'm trying to atach multiple terminals to a single screen session, but the terminals are differnt sizes... any way to have screen resize them properly for both terminals?
Back to top
View user's profile Send private message
meowsqueak
Veteran
Veteran


Joined: 26 Aug 2003
Posts: 1549
Location: New Zealand

PostPosted: Mon Mar 29, 2004 4:25 am    Post subject: Reply with quote

If you're using the -x flag to multiplex the screen sessions, then I think screen will only allow one 'size' at a time, since it's the same program in each instance. I find that the program inside the screen only responds to xterm resizes when it's the last and final instance open. If you have any others detached or active then it doesn't update.
Back to top
View user's profile Send private message
MooktaKiNG
Guru
Guru


Joined: 11 Nov 2002
Posts: 326
Location: London, UK

PostPosted: Mon Mar 29, 2004 9:06 am    Post subject: Reply with quote

Is it possible to split the screen verticaly in screen?

Thanks
_________________
http://www.mooktakim.com
Athlon XP 2001, Giga-Byte GA-7VRXP MB, 640Mb DDR RAM 333MHz, MSI Geforce 4800SE 128Mb DDR, 40x12x48 Liteon CDRW drive, Flower Cooler, ADSL Router
Back to top
View user's profile Send private message
meowsqueak
Veteran
Veteran


Joined: 26 Aug 2003
Posts: 1549
Location: New Zealand

PostPosted: Mon Mar 29, 2004 11:28 pm    Post subject: Reply with quote

MooktaKiNG wrote:
Is it possible to split the screen verticaly in screen?


Anything is possible, especially with the source code, however screen does not do this.
Back to top
View user's profile Send private message
dhurt
Apprentice
Apprentice


Joined: 14 May 2003
Posts: 278
Location: Davis, CA

PostPosted: Tue Jun 01, 2004 6:40 pm    Post subject: Reply with quote

Great tips in this thread, thanks. :D
_________________
"And isn't sanity really just a one-trick pony, anyway? I mean, all you get is one trick, rational thinking, but when you're good and crazy, ooh ooh ooh, the sky's the limit!" -- The Tick
Back to top
View user's profile Send private message
nadezhkin
n00b
n00b


Joined: 01 Jun 2004
Posts: 3

PostPosted: Fri Jun 18, 2004 10:00 am    Post subject: Re: the beauty of screen+script+emerge Reply with quote

Great tips !!!
Thanks a lot :D
But what about ssh-X forwarding and screen
it seems to be a problem
mb this help
[url]http://www.deadman.org/sshscreen.html[/url]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum