交互式输入输出程序实例
来源:互联网 发布:怎么注册淘宝客 编辑:程序博客网 时间:2024/05/23 00:10
交互式输入输出程序演练:
Shell实例1:
[root@ChangerLee顺序结构]#cat read-echo.sh
#!/bin/bash
#read与echo的配合实例
echo-e "接受输入输出IP地址\t:"
readipaddr
echo"my ip address is $ipaddr"
[root@ChangerLee顺序结构]#sh read-echo.sh
接受输入输出IP地址 :
192.168.1.1
myip address is 192.168.1.1
[root@ChangerLee顺序结构]#cat read-echo1.sh
#!/bin/bash
#接收输入并且输出
now_time=`date+%F,%H:%M:%S`
read-p "plz input your username:" username
read-p "plz input your password:" password
password_md5=$(echo$password|md5sum|awk '{print $1}')
echo-e "${now_time}\n系统为你生成用户名:$username,密码为:$password_md5"
Shell实例2:
[root@ChangerLee顺序结构]#sh read-echo1.sh
plzinput your username:ChangerLee
plzinput your password:bkb
2016-08-06,11:19:50
系统为你生成用户名:ChangerLee,密码为:c569b9989319c725420a4f7e5fcf20d7
Shell实例3:
[root@ChangerLee顺序结构]#cat read-echo2.sh
#!/bin/bash
#时间输出文件
test$# -eq 2
if [$? -eq 0 ]
then
#fileyour select exists!!!
test-f $1
if[ $? -eq 0 ]
then
echo"文件${1}存在"
else
touch${1}
echo-e "文件${1}不存在\n系统已经为你创建:`ls${1}`"
fi
test-f $2
if[ $? -eq 0 ]
then
echo"文件${1}存在"
else
touch${2}
echo-e "文件${2}不存在\n系统已经为你创建:`ls${2}`"
fi
#putsystime to flie your select
echo"`date +%F\ %H-%M-%S`">$1
echo"`date +%F\ %H-%M-%S`">$2
echo"$1:`cat $1`"
echo"$2:`cat $2`"
else
echo"Just need two argument!!!"
fi
[root@ChangerLee顺序结构]#sh read-echo2.sh file file1
文件file不存在
系统已经为你创建:file
文件file存在
file:2016-08-0612-04-23
file1:2016-08-0612-04-23
- 交互式输入输出程序实例
- 交互式实例
- OpenGL交互式程序实现
- scanf()与交互式程序
- java输入输出流实例
- 交互式
- (十七)SVG 实例-可交互式中国地图
- 使用cmd模块实现交互式程序
- 使用cmd模块实现交互式程序
- 应用SoRayPickAction类的交互式程序
- 用pexpect做交互式的程序
- Java——创建交互式Web程序
- 网络交互式-计算器程序-Java程序设计
- 交互式程序的字符读取技巧
- matlab实现简单的交互式程序
- 交互式数据包处理程序 Scapy 入门指南
- 尝试——交互式程序编写
- 经典c程序 输入输出
- UVA 11039Building designing
- 美国 ZIP Code 一览表
- 走格子问题
- Python pickle模块学习(超级详细)
- error LNK2026: module unsafe for SAFESEH image.E:\myproject\hellocpp\ffmpeg_qt\avformat.li
- 交互式输入输出程序实例
- charles 抓mac
- Incompatible ssh peer (no acceptable kex algorithm)
- linux定时任务的设置
- 'telnet' 不是内部或外部命令,也不是可运行的程序或批处理文件。
- 头像上传裁剪预览功能-java
- mysql导出数据结构
- Android设计模式之一个例子让你彻底明白装饰者模式(Decorator Pattern)
- 数据结构实验之二叉树四:还原二叉树