screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to run command automatically after running screen?


From: Micah Cowan
Subject: Re: How to run command automatically after running screen?
Date: Tue, 07 Apr 2009 07:33:16 -0700
User-agent: Thunderbird 2.0.0.21 (X11/20090318)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ZelluX wrote:
> Hi, all
> 
> I'm trying to write a test script for xen hypervisor, it works like this:
> 1. Run screen with two windows open
> 2. On the second window, run _sudo xm create my-domU.conf_, and then run
> _sudo xm console 2_ to attach to the console of domainU
> 3. After domainU is started, automatically login and run test scripts on
> domainU
> 
> Now my problem is that how to automatically run scripts after screen is
> started? And in addition does anybody know how to automatically login in
> domainU?

You may be able to do all of this with the screen "stuff" command. Your
screenrc might look something like:

screen # your first window
screen # your second window, now selected
stuff "sudo xm create my-domU.conf\012" # send this as input to shell
stuff "sudo xm console 2\012"
stuff "USERNAME\012"
stuff "PASSWORD\012"
...

The main problem is that screen may send this input too quickly to be
handled, particularly if xm flushes input before beginning to read (most
likely the "stuffed" input will be entered before the program has been
executed). The "sleep" command doesn't help much here: it's only
designed to pause so you can see a message; in my experiments the shell
hasn't even started yet before sleep takes effect.

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer.
Maintainer of GNU Wget and GNU Teseq
http://micah.cowan.name/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknbZCsACgkQ7M8hyUobTrFDywCgjIXrLA5IOgZkek0Nb1faI9eN
JNcAn2mcMeiWzgHSExJYf5vKTSY1o+p2
=SREc
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]