Help in creating an .sh script
I would like some help changing a script I have for my asus, to switch the display between LCD/VGA.
Basically, what I have in the file is: Code:
echo `echo $1 | sed 's/.*0*6\(.\).*/\1/'` >/proc/acpi/asus/disp Can anyone help me? What I need is to change the script to: if (value in file == 1), change to 3 if (value in file == 3), change to 1 and change to 1 again (there's a bug in the acpi4asus and it only works if the value is changed to 1 two times...go figure. How can I do this? |
$1 is the first argument to the script or function. It takes a pattern like something0006Nsomething and extracts the N part. So only one character is output and echoed to /proc/aspci/asus/disp.
|
The "$1" is the first argument given to the script. So if you called the script as:
Code:
bash$ ./myscript.sh test If you want to make some logical decisions based on that input, you could do something like: Quote:
But in your post you mentioned a file. Do you want to read the value from a known file rather than using the arguments to the script? By the way, this would probably be better off in Programming, for future reference. |
Quote:
I've found that the $1 comes from: Code:
|
Quote:
Because the decision should be made automatically by the script (I just want to press the button in my laptop), the script should be something along the lines of var x = read the value in the file /proc/acpi/asus/disp if (x == 1) echo 3 > /proc/.../disp else echo 1 > .../disp echo 1 > .../disp |
Moved: This thread is more suitable in the Programming forum and has been moved accordingly to help your thread/question get the exposure it deserves.
|
All times are GMT -5. The time now is 04:07 PM. |