LINUX-Shell编程实验报告
更新时间:2024-04-18 00:01:01 阅读量: 综合文库 文档下载
《LINUX管理与应用》课程实验报告
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
实验目的: 理解Shell程序的设计方法;熟悉Shell程序编辑、运行、调试方法与过程。 实验内容: 实验内容和目的 (1)Shell 简单编程 用户名回显程序;if-then、if-then-else语句使用;for语句、while语句使用 (2)较复杂的考勤模拟shell程序设计 实验环境 微机、WINDOWS XP、QUICK LINUX、VMWARE虚拟机软件 实验重点:SHELL编辑、运行过程;SHELL变量的使用,分支语句的设实验重点及难点 计,循环语句的设计 实验难点:SHELL语句的使用方法 实验过程(实验过程、实验结果及实验分析)
一、实验过程 1. 编写一个简单的回显用户名的shell程序 2. 使用if-then语句创建简单的shell程序 3. 使用if-then-else语句创建一个根据输入的分数判断是否及格的shell程序 4. 使用for语句创建简单的shell程序 5. 使用while语句创建一个计算1-5的平方的shell程序 6. 用shell设计一个模拟考勤程序 二、实验结果 1.编写一个简单的回显用户名的shell程序 #vi dat #!/bin/bash #filename:dat echo \echo `date` echo Wish you a lucky day! #chmod +x dat #./dat 2. 使用if-then语句创建简单的shell程序 #vi bbbb #!/bin/bash #filename:bbbb echo -n \read ANSWER if [ $ANSWER = N -o $ANSWER = n ] then echo \ \fi
#chmod +x bbbb #./bbbb 3. 使用if-then-else语句创建一个根据输入的分数判断是否及格的shell程序 #vi ak #!/bin/bash #filename:ak echo -n \read SCORE echo \if [ $SCORE -ge 60 ]; then echo -n \else echo -n \fi echo -n \read $GOOUT #chmod +x ak #./ak 4. 使用for语句创建简单的shell程序 #vi mm #!/bin/bash #filename:mm for ab in 1 2 3 4 do echo $ab
done #chmod +x mm #./mm 5. 使用while语句创建一个计算1-5的平方的shell程序 #vi zx #!/bin/bash #filename:zx int=1 while [ $int -le 5 ] do sq=`expr $int \\* $int` echo $sq int=`expr $int + 1` done echo \#chmod +x zx #./zx 6. 用shell设计一个模拟考勤程序,实现如下功能选择界面: 1:上班签到2:下班签出3:缺勤信息查阅 # vi testshell #! /bin/bash #filename:shelltest exsig=0 while true; do echo \ echo \欢迎使用本系统----\ echo \上班签到\
echo \下班签出\ echo \考勤信息查询\ echo \退出系统\ echo \ echo \ echo \请输入你的选项:\ read choice case $choice in 1)echo \请输入你的名字:\ read name echo \请输入你的密码:\ read password if test -r /home/user/userinfo.dat then while read fname fpassword do echo \ echo \ if test \ then break fi done < /home/user/userinfo.dat else echo System Error:userinfo.dat does not exist! fi if test \ then echo \不存在该用户!\ elif test \ then echo \密码不正确!\ else hour=`date +%H` if test \ then echo \你迟到了!\ echo \上班迟到---日期:`date`\ else echo \早上好,$name!\ fi fi ;; 2)echo \请输入你的名字:\
read name echo \请输入你的密码:\ read password if test -r /home/user/userinfo.dat then while read fname fpassword do if test \ then break fi done < /home/user/userinfo.dat else echo System Error:userinfo.dat does not exist! fi if test \ then echo \不存在该用户!\ elif test \ then echo \密码不正确!\ else hour=`date +%H` if test \ then echo \你早退了!\ echo \下班早退----日期:`date`\ else echo \再见,$name!\ fi fi ;; 3)echo \请输入你的名字:\ read name echo \请输入你的密码:\ read password if test -r /home/user/userinfo.dat then while read fname fpassword do if test \ then break fi
done < /home/user/userinfo.dat else echo System Error:userinfo.dat does not exist! fi if test \ then echo \不存在该用户!\ elif test \ then echo \密码不正确!\ else echo \你的记录:\ echo \ cat -b /home/user/check.dat|grep $name echo \ fi ;; 4)echo \欢迎你的使用,再见!\ exsig=1 ;; *)echo \请输入合法的选项!\ ;; esac if test \ then break fi done 七.试验运行结果: #chmod +x testshell #./testshell
三、实验分析 通过这次实验,我懂得了定义SHELL程序设计中的变量,掌握了SHELL程序中LINUX基本命令的使用,理解了Shell程序的设计方法,并且熟悉了Shell程序编辑、运行、调试方法与过程。这为我日后继续深入学习Linux课程打下基础。
正在阅读:
LINUX-Shell编程实验报告04-18
幸福在我心中作文600字06-21
2C级检修脱硫主烟道防腐工程施工方案08-14
痰热清注射液治疗慢性阻塞性肺疾病急性加重期35例效果观察05-31
定义与命题练习题02-13
七夕活动总结范本八篇04-03
通用版高考语文一轮复习专题十七微写作课时达标39微写作-含答案01-15
房地产金融练习题和答案06-15
房地产营销客户定位04-14
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 编程
- 实验
- 报告
- LINUX
- Shell
- 2013年潍坊市学业水平考试数学试卷分析
- 猫道设计与施工方案(修改)
- 中小学生转学手续该如何办理 - 图文
- 快乐英语六年级下册全部英语单词
- 格力的6σ管理
- 机械工程材料学
- 四川省宜宾市高2018届高三第三次诊断考试化学试题 含解析
- 园林绿化工程(讲义) - 图文
- 内循环流化床冷渣器内颗粒混合特性数值模拟 - 图文
- 史上最全PKPM SATWE参数设置介绍 - 图文
- 大唐题库 - 图文
- 学前教育科学研究与论文写作 笔记整理 自学考试
- 虚拟光驱软件酒精Alcohol 120%详细使用图文教程
- 创新中国章节答案
- (2014版)植物生理生化网上作业题-提交
- 学习小组建设感言
- 厦门大学网络教育第一学期英语(小抄版)含复习题
- 大学军事理论考试试题复习资料大全
- C程序设计教程课后习题答案吉顺如版
- 大工15秋《SQL数据库系统及应用》在线作业2 100分答案