LINUX-Shell编程实验报告_第1页
LINUX-Shell编程实验报告_第2页
LINUX-Shell编程实验报告_第3页
已阅读5页,还剩3页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、word 格式-可编辑-感谢下载支持LINUX 管理与应用课程实验报告实验目的:理解 Shell 程序的设计方法;熟悉 Shell 程序编辑、运行、调试方法与过程。实验内容和目的实验内容:Shell 简单编程用户名回显程序;if-then、if-then-else 语句使用;for 语句、while 语句使用较复杂的考勤模拟 shell 程序设计实验环境微机、WINDOWSXP、QUICKLINUX、VMWARE 虚拟机软件实验重点:SHELL 编辑、运行过程;SHELL 变量的使用,分支语句的实验重点及难点计,循环语句的设计实验难点:SHELL 语句的使用方法实验过程(实验过程、实验结果及实

2、验分析)一、实验过程word 格式-可编辑-感谢下载支持编写一个简单的回显用户名的 shell 程序if-thenshell 程序if-then-else 语句创建一个根据输入的分数判断是否及格的shell 程序forshell 程序while1-5shell 程序用 shell二、实验结果编写一个简单的回显用户名的 shell 程序#vi dat #!/bin/bash #filename:datecho Mr.$USER,Today is: echo dateecho Wish you a lucky day!#chmod+x#./datif-thenshell 程序#vi bbbb #!

3、/bin/bash #filename:bbbbecho -n Do you want to continue: Y or N read ANSWERif $ANSWER = N -o $ANSWER = n thenecho your answer is quit! fi#chmod+xbbbb#./bbbbword 格式-可编辑-感谢下载支持if-then-else 语句创建一个根据输入的分数判断是否及格的shell 程序#vi ak #!/bin/bash #filename:akecho -n please input a score: read SCOREecho You input

4、 Score is $SCORE if $SCORE -ge 60 ;thenecho -n Congratulation!You Pass the elseecho -n Sorry!You Fail the examination! fiecho -n press any key to continue! read $GOOUT#chmod+xak#./akforshell 程序#vi mm #!/bin/bash #filename:mmfor ab in 1 2 3 4 doecho $ab done#chmod+xmm#./mmword 格式-可编辑-感谢下载支持while1-5sh

5、ell 程序#vi zx #!/bin/bash #filename:zx int=1while $int -le 5 dosq=expr $int * $intecho $sqint=expr $int + 1 doneecho Job completed#chmod+xzx#./zx用 shell1:2:3:缺勤信息查阅# vitestshell#! /bin/bash #filename:shelltest exsig=0while true; do echo echo-欢迎使用本系统echo1. 上班签到echo2. 下 班 签 出 echo3. 考勤信息查询echo4. 退出系统ec

6、hoecho word 格式-可编辑-感谢下载支持echo 请输入你的选项: read choicecase $choice inechoreadnameecho 请输入你的密码: read passwordif test -r /home/user/userinfo.dat thenwhile read fname fpassword doecho $fname echo $fpasswordif test $fname = $name thenbreakfidone /home/user/check.dat elseecho 早上好,$name!fifi;echoreadnameecho

7、请输入你的密码: read passwordif test -r/home/user/userinfo.dat thenwhile read fnamefpassword doword 格式-可编辑-感谢下载支持if test $fname = $name thenbreakfidone /home/user/check.dat elseecho 再见,$name!fifi;echoreadnameecho 请输入你的密码: read passwordif test -r/home/user/userinfo.dat thenwhile read fnamefpassword doif tes

8、t $fname = $name thenbreakfidone /home/user/userinfo.dat elseecho System Error:userinfo.dat does not exist!fiif test $fname != $name thenecho 不存在该用户!elif test $fpassword != $password thenword 格式-可编辑-感谢下载支持echo 密码不正确!elseecho你的记录echocat -b /home/user/check.dat|grepechofi;echoexsig=1;*)echo 请输入合法的选项!;esacif test $exsig = thenbreakfi done七试验运行结果:#c

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论