- 论坛徽章:
- 0
|
是在一个教程上看到的,一个是对键盘指示灯的操作,一个是shell编的时钟。
#
# Linux Shell Scripting Tutorial (LSST) v1.05, March 2001
# Author: Vivek G Gite
#
# Run as:
# $ chmod +x kbdfun
# $ ./kbdfun
#
echo -e "\033[0q Turning all kbd -LED lights off"
echo "* * * Press CTRL + C to stop"
while [ 1 ]
do
echo -e "\033[1q Scroll On Other Off"
sleep 1
echo -e "\033[2q Num On Other Off"
sleep 1
echo -e "\033[3q Caps On Other Off"
sleep 1
done
下面这个是始终:
#!/bin/bash
#
# Linux Shell Scripting Tutorial 1.05r3, Summer-2002
#
# Written by Vivek G. Gite <vivek@nixcraft.com>
#
# Latest version can be found at http://www.nixcraft.com/
#
# Q17
# To run type at $ promot as
# $ q17 &
#
echo
echo "Digital Clock for Linux"
echo "To stop this clock use command kill pid, see above for pid"
echo "Press a key to continue. . ."
while :
do
ti=`date +"%r"`
echo -e -n "\033[7s" #save current screen postion & attributes
#
# Show the clock
#
tput cup 0 69 # row 0 and column 69 is used to show clock
echo -n $ti # put clock on screen
echo -e -n "\033[8u" #restore current screen postion & attributs
#
#Delay fro 1 second
#
sleep 1
done
是可以运行,但是显示有乱码。不知道是shell版本不对,还是怎么回事。按理说那个教程是比较老的,我这个新的shell应该没什么问题阿。我用的是ubuntu9.10.还请高手指点。
[ 本帖最后由 lo_529 于 2010-1-17 22:07 编辑 ] |
|