Sunday, April 10, 2011

How to Make a Shell Script in Linux?

Yeah, like you say, it's for newbie only :D. We will make a shell script to display voltage in mV and current in mA like I post before. Shell script can contain one or more lines of instruction usually issued in Terminal.

# Open your editor (I always choose vi) type:
cat /proc/acpi/battery/C1AC/state | grep "present voltage"
cat /proc/acpi/battery/C1AC/state | grep "present rate"
# Don't forget to replace "C1AC" with your own battery type

# Save these shell script, for example,

# Change the mode of file so that it can be executed
chmod +x
# Run this script by typing this instruction in your Terminal:
# The output will look like this:
present voltage:         16778 mV
present rate: 702 mA
Shell script will simplify our life. Believe me and enjoy!

No comments: