Re: Problems with decode-dimms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2 Sep 2019 09:56:38 -0500, Hans L wrote:
> So I ended up running:
> $ sudo su
> # echo ee1004 0x50 > /sys/bus/i2c/devices/i2c-1/new_device
> # echo ee1004 0x51 > /sys/bus/i2c/devices/i2c-1/new_device
> # echo ee1004 0x52 > /sys/bus/i2c/devices/i2c-1/new_device
> # echo ee1004 0x53 > /sys/bus/i2c/devices/i2c-1/new_device
> [Ctrl-D]
> 
> For some reason which I still don't understand, I couldn't just run
> each command directly with sudo:
> $ sudo echo eeprom 0x50 > /sys/bus/i2c/devices/i2c-1/new_device
> bash: /sys/bus/i2c/devices/i2c-1/new_device: Permission denied

Can be surprising at first but is easily explained. The shell processes
the redirection before executing the command. So it is
opening /sys/bus/i2c/devices/i2c-1/new_device as yourself, *then*
executes echo as root. What you really want to do is:

$ such sh -c "echo ee1004 0x50 > /sys/bus/i2c/devices/i2c-1/new_device"

which will force the user change to happen *before* the redirection.

-- 
Jean Delvare
SUSE L3 Support



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux