hong zhang wrote:
List,

I have a question of python using echo.

POWER = 14
return_value = os.system('echo 14 > /sys/class/net/wlan1/device/tx_power')

can assign 14 to tx_power

But return_value = os.system('echo $POWER > /sys/class/net/wlan1/device/tx_power')

return_value is 256 not 0. It cannot assign 14 to tx_power.

What problem is it?

os.system("echo $POWER") returns 0 but
os.system("echo $POWER > /sys/class/net/wlan1/device/tx_power") returns 256.

Did you think that you could say:

    POWER = 14
return_value = os.system('echo $POWER > /sys/class/net/wlan1/device/tx_power')

in a Python script and that would do the same as:

return_value = os.system('echo 14 > /sys/class/net/wlan1/device/tx_power')

That won't work because 'POWER' exists only in Python and 'echo' is
being run in the (Linux?) shell.

You could try creating the command-line and then passing it to 'system':

return_value = os.system('echo %s > /sys/class/net/wlan1/device/tx_power' % POWER)
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to