Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Why can't I use echo $1 > /sys/class/backlight/acpi_video0/brightness in a simple bash script?

It gives me the error: echo: write error: Invalid argument.

share|improve this question
Having the same issue while trying to do the same thing. I've tried things like function brightness { bright=$1; sudo su -c 'echo "$bright" > /sys/class/backlight/acpi_video0/brightness'; } too, but I still haven't figured it out. – seafangs Nov 2 '12 at 12:15

2 Answers

Try echo "$1" > /sys/class/backlight/acpi_video0/brightness.

I bet the shell is expanding $1 and thus echo thinks it is receiving a bunch of arguments, rather than a string.

share|improve this answer

You should check what the actual value of $1 is. This error means you are trying to write an invalid value -- either it's out of range or just in general not a meaningful value.

At a glance, it appears that it accepts an integer in the range 0 to 8 (for me at least).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.