linux系统编程界面实验报告,linux操作系统实验报告_shell简单编程.doc

253b171540df25e1b84436cbe50dfc72.giflinux操作系统实验报告_shell简单编程.doc

操作系统实验报告 院系 机电与信息工程学院 实验 日期 2012年 xx月 x 日 姓名 xxx 学号 xxxxxxxxxxxx 专业 计算机 年级 xx级 同组者(姓名、学号) 无 实验题目 一、实验目的 ( 包括实验内容,实验原理,实验目标) 1)利用 Shell编程,实现时间密码的验证 2)编写一个小程序,计算用户期望时间与系统时间的差值 3)编写一个 Shell程序,使得程序在系统时间分钟值为 5的倍数的时,自动备份此目录下的 .png 文件到 backup中(选做) 二、实验设计 (包括 设计思路 , 数据结构 ,程序流程图,关键代码说明) 使用 linux虚拟机完成实验要求。 三、 实验 结果 ( 包括 运行结果,结果分析) 1)利用 Shell编程,实现时间密码的验证 附源代码如下 /bin/bash Program User can test the timepassword.用户可以验证时间密码 History2012/11/03 First release PATH/bin/sbin/usr/bin/usr/sbin/usr/sbin/usr/local/bin/usr/local/sbin/bin export PATH Datedate YmdHM read -p “Please the password “ password while “password“ “Date“ do read -p “You have the wrong password , please the right one “ password done if “password“ “Date“ ; then echo “Congratulations You have won the this test “ exit 0 fi 2)编写一个小程序,计算用户期望时间与系统时间的差值 附源代码 /bin/bash Program User can get the days to his expected date. 得到距离用户期望日期的天数或者已过天数。 History2012/11/04 First release PATH/bin/sbin/usr/bin/usr/sbin/usr/sbin/usr/local/bin/usr/local/sbin/bin export PATH Timedate Ymd echo “Now is the time Time“ read -p “Enter the date“ date1 date_testecho date1 | grep 0-98 if “date_test“ ;then echo “Wrong of date Please try again“date1 exit 1 fi date_nowdate s date_expdate date“date1“ s date_dif_sdate_exp-date_now date_difdate_dif_s/60/60/24 if “date_dif“ -gt “0“ ;then echo “date_dif1 days later to your expected date.“ elif “date_dif“ -lt “0“ ;then echo “Your days is -1*date_dif days before.“ else echo “Your expected day is today.“ fi 3)编写一个 Shell程序,使得程序在系统时间分钟值为 5的倍数的时,自动备份此目录下的 .png 文件到 backup中(选做) 源代码 /bin/bash Program User can backup the png files every 5 minutes. History2012/11/04 First release PATH/bin/sbin/usr/bin/usr/sbin/usr/sbin/usr/local/bin/usr/local/sbin/bin export PATH echo “This program helps you to backup the png files every 5 minutes.“ backdir“./backup“ minutedate M nextminute5 if next -eq “0“ ;then echo “backing“ cp *.png backdir echo “finished“ else echo “Cant backup this minute“ fi 四、实验总结 (包括实验效果分析,心得体会,遗留问题) 在用 sh的时候,出现了点小问题,最后通过百度,成功解决了问题。 本次实验学到了很多知识。 教师 评语 成绩 教师签名 年 月 日 注此表各栏可延伸。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值