版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 北师大版语文七上《说虎》课件
- 小学数学教资面试历年真题参考答案及解析
- 2026财会岗事业单位结构化面试易错题题库带答案
- 计算机岗事业单位面试高频题题库含答案
- 文字综合岗事业单位面试专项训练含答案
- 幼儿园工作管理手册
- 暖房施工组织设计
- 高中英语翻译能力测试试卷及答案
- 大学管理企业财务管理原理测试试卷及答案
- 颌下区肉芽肿多学科决策模式中国专家共识(2026版)
- 小学道德与法治新部编版六年级上册全册知识点(2026秋)
- 2026年秋招:中国建材笔试题及答案
- 自考09462 国际贸易实务(英语)(短句背诵版适配答题)
- 2026矿区微电网白皮书 多源协控 构建绿色矿区韧性微网-阳光电源
- 新苏教版三年级数学上册第七单元《1.数量关系的分析(1)》课件
- 2026年秋大象版(新教材)小学科学五年级上册教学计划及进度表
- 空压机日常巡检记录
- 地铁通风空调竣工验收监理评估报告
- 2026智联招聘笔试题库及答案
- EDA技术及应用项目教程 教学大纲
- 2025年度中国展览数据统计报告
评论
0/150
提交评论