Bash script in which you enter numerical value and execute with that value

0

I have this little script in Bash to raise or lower the brightness of my laptop:

#!/bin/bash
clear
sudo tee /sys/class/backlight/radeon_bl0/brightness <<< 10

In which "10" is the numerical value to change.

My question is: How do I open the script from a terminal, ask for a number, and then execute that number?

    
asked by Alejandro Lopez 20.08.2017 в 06:02
source

2 answers

2

Do not worry, I've already solved it. Here I leave the answer in case someone needs it.

#!/bin/bash
clear
echo Por favor, ingresa el brillo que deseas en tu pantalla 
read varbright
sudo tee /sys/class/backlight/radeon_bl0/brightness <<< $varbright
    
answered by 20.08.2017 в 06:16
2

You could use the system parameters, read them and execute with those values.

When you run something like:

Program.sh 10

Inside programa.sh you can read the parameter 10 with $ 1, and you could write something like:

#!/bin/bash
clear
sudo tee /sys/class/backlight/radeon_bl0/brightness <<< $1

$ 0 would be the name of the file, in this example it would be program1.sh

$ 1 would be the first parameter, here it would be 10

And so on ...

    
answered by 20.08.2017 в 11:06