标题: [原创代码] shell工具 [打印本页]
作者: 111 时间: 2015-7-4 20:04 标题: shell工具
- #!/system/bin/sh
- root="`id`"
- case $root in
- uid=0* )
- ;;
- *)
- echo Please root first
- exit
- ;;
- esac
- if busybox [ -e /system/bin/clear ]
- then
- break
- else
- echo Please install busybox first.
- exit
- fi
- until cat /data/mjump
- do
- clear
- echo "Enter the keys:"
- read pass
- rps="$((`date +%H%m`*`date +%d`))"
- case $pass in
- $rps)
- echo " ">/data/mjump
- ;;
- *)
- echo 'Error!'
- sleep 2
- ;;
- esac
- done
- clear
- echo "Welcome to use myx program..."
- sleep 2
- while
- do
- clear
- echo "Today is `date` "
- echo "This system is `uname` `uname -r`"
- echo "This is my first Shell."
- echo "0.exit 1-3.watch my composition"
- echo "4.book reader 5.shutdown 6.notebook"
- echo "7.calculate average 8.calculator"
- echo "9.call or send SMS a.install a package"
- echo "b.lock screen c.make a seed of picture"
- echo "d.start talk AI beta e.backup system"
- echo "f.start telnet server g.start web server"
- echo "h.start ftp server i.make a vcf file"
- echo "j.make random k.make a goods list"
- echo " next.next page"
- echo 'Input a number or letter between 0 to m:'
- read s
- case $s in
- 0)
- echo "Thanks used my Shell."
- break
- ;;
-
- 1)
- clear
- echo "Hi,I m the phone's master."
- echo "My name is ******."
- echo "I like to play computer,"
- echo "so I want to be a computer programmer."
- echo "I want to write a system like the Android,"
- echo "then I must \"good good study,day day up\"."
- sleep 10
- ;;
-
- 2)
- clear
- echo "My father is *******."
- echo "And my mother is *******."
- echo "I love them."
- sleep 5
- ;;
-
- 3)
- clear
- echo "I think Shell is a good program language."
- echo "Of course!batch is a good program language,too."
- echo "C++ is good,but it is difficult."
- sleep 10
- ;;
-
- 4)
- clear
- echo "Write the book path:"
- read bopa
- more $bopa
- sleep 1
- ;;
-
- 5)
- reboot -p
- ;;
-
- 6)
- clear
- echo "Save to:"
- read satx
- echo >$satx
- while
- do
- clear
- echo "Input exit to exit"
- cat $satx
- echo "Input:"
- read intx
- case $intx in
- exit)
- break 1
- ;;
- *)
- echo "$intx" >> "$satx"
- ;;
- esac
- done
- echo OK!
- sleep 2
- ;;
-
- 7)
- clear
- SCORE="0"
- AVERAGE="0"
- SUM="0"
- NUM="0"
- while
- do
- echo "Enter your $(($NUM+1)) number('q' for calculate): "
- read SCORE
- if [ "$SCORE" == "q" ]
- then
- echo "Average rating: $AVERAGE."
- sleep 5
- break 1
- else
- SUM=$(($SUM+$SCORE))
- NUM=$(($NUM+1))
- AVERAGE=$(($SUM/$NUM))
- fi
- done
- ;;
-
- 8)
- clear
- echo "Write your equation:"
- read ss
- echo "${ss}=$((${ss})) "
- sleep 5
- ;;
-
- 9)
- clear
- echo " Your phone number:"
- read sdt
- echo "Your phone number is $sdt"
- echo "Input 1 to call"
- echo "Input 2 to send SMS"
- echo 'Input a number between 1 to 2:'
- read ab
- case $ab in
- 1)
- service call phone 2 s16 $sdt
- ;;
-
- 2)
- am start -a android.intent.action.SENDTO -d sms:$sdt --ez exit_on_sent true
- ;;
-
- *)
- echo "Error!"
- sleep 2
- ;;
- esac
- ;;
-
- a)
- clear
- echo "Write the package path:"
- read pp
- pm install "$pp"
- ;;
-
- b)
- input keyevent 26
- ;;
-
- c)
- clear
- echo "Write the cabinet path:"
- read cab
- echo " Write the picture path:"
- read pic
- cat $cab >> $pic
- echo 'OK!'
- sleep 1
- ;;
-
- d)
- echo "Welcome to use talk AI" >/cache/talk.txt
- ais="Hello,I'm talk AI."
- while
- do
- echo "`date` AI" >>/cache/talk.txt
- echo "$ais" >>/cache/talk.txt
- echo " ">>/cache/talk.txt
-
- clear
- cat /cache/talk.txt
- echo "----------------------------"
- echo 'You say:'
- read say
-
- echo "`date` You" >>/cache/talk.txt
- echo "$say" >>/cache/talk.txt
- echo " " >>/cache/talk.txt
-
- case $say in
- bye)
- break 1
- ;;
-
- *)
- ais="Sorry,I don't know what do you say."
- ;;
- esac
- done
- ;;
-
- e)
- clear
- echo "Please wait......"
- dd if=/dev/block/mtdblock11 of=/sdcard/system.img
- echo 'OK!'
- sleep 1
- ;;
-
- f)
- telnetd -l /system/bin/sh
- echo OK!
- sleep 1
- ;;
-
- g)
- httpd -h /mnt/My-space/
- echo OK!
- sleep 1
- ;;
-
- h)
- tcpsvd -vE 0.0.0.0 21 ftpd /
- ;;
-
- i)
- clear
- echo "Write the name:"
- read nam
- echo "Write the phone number:"
- read num
- echo "Write the save path:"
- read vcs
- echo "BEGIN:VCARD" >$vcs/$nam.vcf
- echo "VERSION:2.1" >>$vcs/$nam.vcf
- echo "N:$nam;" >>$vcs/$nam.vcf
- echo "FN:$nam" >>$vcs/$nam.vcf
- echo "TEL;CELL;VOICE:$num" >>$vcs/$nam.vcf
- echo "END:VCARD" >>$vcs/$nam.vcf
- echo "Saved to $vcs/$nam.vcf"
- sleep 1
- ;;
-
- j)
- clear
- while
- do
- cat /proc/sys/kernel/random/uuid | awk -F- '{printf("%s ",$1)}'
- sleep 1
- done
- ;;
-
- k)
- clear
- coln(){
- echo "Input Unit-price:"
- read unit
- echo "Input Quantity:"
- read quty
- lisn="$((${lisn}+1))"
- toal="$((${unit}*${quty}))"
- ttal="$((${ttal}+${toal}))"
- }
- lisn="0"
- ttal="0"
- echo "Save to:"
- read sals
- echo "Save for [1.txt 2.csv]:"
- read bcfs
- case $bcfs in
- 1)
- echo "Goods list">$sals
- echo "Num Goods Unit-price Quantity Total" >>$sals
- echo "-----------------------------------">>$sals
- while
- do
- clear
- cat $sals
- echo "Input Goods(Input exit to save):"
- read gods
- case $gods in
- exit)
- echo "-----------------------------------">>$sals
- echo "Total:$ttal" >>$sals
- echo "OK!"
- sleep 1
- break 1
- ;;
- *)
- coln
- echo "$lisn $gods $unit $quty $toal" >>$sals
- ;;
- esac
- done
- ;;
- 2)
- echo "Goods list">$sals
- echo "Num,Goods,Unit-price,Quantity,Total" >>$sals
- while
- do
- clear
- cat $sals | awk -F, '{printf("%s %s %s %s %s\n", $1, $2, $3, $4, $5)}'
- echo "-----------------------------------"
- echo "Input Goods(Input exit to save):"
- read gods
- case $gods in
- exit)
- echo "Total,$ttal" >>$sals
- echo "OK!"
- sleep 1
- break 1
- ;;
- *)
- coln
- echo "$lisn,$gods,$unit,$quty,$toal" >>$sals
- ;;
- esac
- done
- ;;
- esac
- ;;
-
- next)
- while
- do
- clear
- echo "Today is `date` "
- echo "This system is `uname` `uname -r`"
- echo "This is my first Shell."
- echo "1.block website 2.find process"
- echo "3.systeminfo"
- echo " back.back to main"
- echo 'Input a number or letter between 1 to 3:'
- read st
- case $st in
- 1)
- clear
- echo "input a domain:"
- read domn
- echo "127.0.0.1 $domn">>/etc/hosts
- echo "OK!"
- sleep 1
- ;;
-
- 2)
- clear
- echo "Input process or pid:"
- read pgd
- ps | grep $pgd
- sleep 10
- ;;
-
- 3)
- while
- do
- clear
- cat /proc/loadavg | awk '{printf("Cpu:%s\n",$1)}'
- cat /proc/meminfo | grep MemTotal:
- cat /proc/meminfo | grep MemFree:
- df | grep /mnt/sdcard | awk '{printf("Diskfree:%sKB/%sKB",$1,$2)}'
- sleep 1
- done
- ;;
-
- back)
- break 1
- ;;
-
- *)
- echo "Error!"
- sleep 2
- ;;
- esac
- done
- ;;
-
- *)
- echo "Error!"
- sleep 2
- ;;
- esac
- done
复制代码
最近学习了shell,做了个小shell工具,在手机上能正常运行,请用Linux人的帮忙在电脑测试一下
作者: gawk 时间: 2015-7-4 23:01
嗯,用来练习语法还行。Linux系统管理员一般不用这样的脚本。
其实你自己用虚拟机搭建一个Linux环境也很简单的。
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |