1,105,312 Community Members

Get installed kernels using python code

Member Avatar
mwaidyanatha
Newbie Poster
1 post since Feb 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi, I want to get installed Xen kernels & initrds in my computer using a python code. When I do a ls /boot I get the following results.

config-2.6.26-2-686
config-2.6.26-2-xen-686
grub
initrd.img-2.6.26-2-686
initrd.img-2.6.26-2-686.bak
initrd.img-2.6.26-2-xen-686
initrd.img-2.6.26-2-xen-686.bak
System.map-2.6.26-2-686
System.map-2.6.26-2-xen-686
vmlinuz-2.6.26-2-686
vmlinuz-2.6.26-2-xen-686
xen-3.2-1-i386.gz

and what I want is "vmlinuz-2.6.26-2-xen-686" & "initrd.img-2.6.26-2-xen-686". We can get the results using lot of string processing but I need a simple way to do this.
Thank You.

Member Avatar
Gribouillis
Posting Maven
3,452 posts since Jul 2008
Reputation Points: 1,140 [?]
Q&As Helped to Solve: 883 [?]
Skill Endorsements: 18 [?]
Moderator
 
0
 

You can start with

import os
L = [x for x in os.listdir("/boot") if "-xen-" in x]
print(L)
Question Answered as of 3 Years Ago by Gribouillis
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: