linux操作系统实验报告_shell简单编程.doc_第1页
linux操作系统实验报告_shell简单编程.doc_第2页
linux操作系统实验报告_shell简单编程.doc_第3页
linux操作系统实验报告_shell简单编程.doc_第4页
linux操作系统实验报告_shell简单编程.doc_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

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

文档简介

操作系统实验报告院系:机电与信息工程学院 实验日期: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.用户可以验证时间密码#History:2012/11/03 First release PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/binexport PATHDate=date +%Y%m%d%H%Mread -p Please input the password : passwordwhile $password != $Date do read -p You have the wrong password , please input the right one : passworddoneif $password = $Date ; then echo Congratulations ! You have won the this test ! exit 0fi 2)编写一个小程序,计算用户期望时间与系统时间的差值 附:源代码#!/bin/bash#Program: User can get the days to his expected date. #得到距离用户期望日期的天数或者已过天数。#History:2012/11/04 First release PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/binexport PATHTime=date +%Y%m%decho Now is the time $Timeread -p Enter the date: date1date_test=echo $date1 | grep 0-98if $date_test = ;then echo Wrong form of date! Please try again:date1 exit 1fi date_now=date +%sdate_exp=date -date=$date1 +%sdate_dif_s=$($date_exp-$date_now)date_dif=$($date_dif_s/60/60/24)if $date_dif -gt 0 ;then echo $($date_dif+1) day(s) 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.#History:2012/11/04 First release PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/binexport PATHecho This program helps you to backup the png files every 5 minutes.backdir=./backupminute=date +%Mnext=$($minute%5)if $next -eq 0 ;then echo backing. cp *.png $backdir echo finishedelse echo Cant backup this minu

温馨提示

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

最新文档

评论

0/150

提交评论