directory wildcard

H

hong zhang

List,

I try to assign value to force_mcs sitting in a wildcard subdirectory /sys/kernel/debug/ieee80211/phy*, but python does not work for that such as:

os.system("echo %i > /sys/kernel/debug/ieee80211/phy*/iwlagn/data/force_mcs" % mcs)

Any right way to do it?

Thanks.

--henry
 
D

Diez B. Roggisch

hong said:
List,

I try to assign value to force_mcs sitting in a wildcard subdirectory /sys/kernel/debug/ieee80211/phy*, but python does not work for that such as:

os.system("echo %i > /sys/kernel/debug/ieee80211/phy*/iwlagn/data/force_mcs" % mcs)

Any right way to do it?

Don't use os system. Use subprocess. Which incidentially is mentioned in
the docs for os.system:

http://docs.python.org/library/os.html#os.system

Then you can pass the "use_shell=True" parameter - which should work in
your case.

Diez
 
J

Jeff McNeil

List,

I try to assign value to force_mcs sitting in a wildcard subdirectory /sys/kernel/debug/ieee80211/phy*, but python does not work for that such as:

os.system("echo %i > /sys/kernel/debug/ieee80211/phy*/iwlagn/data/force_mcs" % mcs)

Any right way to do it?

Thanks.

--henry

I'd ditch the echo business altogether. 2.x. Not tested.

import glob

mcs = get_mcs_from_somewhere()
for i in glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/
force_mcs'):
with open(i, 'w') as f:
print >>f, mcs

Thanks,

Jeff
mcjeff.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,976
Members
47,536
Latest member
MistyLough

Latest Threads

Top