|
|
|
|
|
|
|
|
|
|
xen-users
RE: [Xen-users] execute command
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
|
|
|
|
|