We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,623 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Get installed kernels using python code

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.

2
Contributors
1
Reply
1 Hour
Discussion Span
2 Years Ago
Last Updated
2
Views
Question
Answered
mwaidyanatha
Newbie Poster
1 post since Feb 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

You can start with

import os
L = [x for x in os.listdir("/boot") if "-xen-" in x]
print(L)
Gribouillis
Posting Maven
Moderator
3,101 posts since Jul 2008
Reputation Points: 1,130
Solved Threads: 761
Skill Endorsements: 11
Question Answered as of 2 Years Ago by Gribouillis

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0523 seconds using 2.64MB