WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

RE: [Xen-users] execute command

To: Xen Users <Xen-users@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-users] execute command
From: Steve Brueckner <steve@xxxxxxxxxxxxxx>
Date: Thu, 5 Jan 2006 16:26:19 -0500
Delivery-date: Thu, 05 Jan 2006 21:32:00 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
Anand wrote:
> Would you mind sharing the script ?
> 
> 
> On 1/6/06, Steve Brueckner <steve@xxxxxxxxxxxxxx> wrote:
> Gémes Géza wrote:
>> Anand írta:
>> 
>>> Is there a way to run a command inside a domX from dom0 and get its
>>> output in dom0 ? 
>>> 
>> ssh (rsh) ?
> 
> I had a similar problem but could not use networking, so I wrote an
> Expect script that opened a console into the domU and executed the
> command. 



Okay, here's a freebie.  This script gets the domU IP.  It requires the xenU
domain ID as an argument.  It is very rough and ugly and tweaked for my
machine (FC4), but maybe it will get you started.  Oh, and it anticipates
that a console might already be open into domU by username "developer".

#!/usr/bin/expect -f
set ID $argv
set timeout -1
spawn xm console $ID
match_max 100000
#wake up the console
sleep .4
send -- "\r"
#there are two cases:
expect {
        #if no console open
        "login:" {
                sleep .1
                send -- "developer\r"
                expect "Password:"
                sleep .1
                send -- "developer\r"
                expect "developer"
        #if console fully open
        } "developer" { }
}
#get ip address
sleep .1
send -- "/sbin/ifconfig eth0 | grep 'inet addr:'\r"
expect "/sbin/ifconfig"
#logout from console
send -- "logout\r"
expect "logout"
sleep .1
send -- ^C"
#expect eof

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users