Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1035115
  • 博文数量: 836
  • 博客积分: 43880
  • 博客等级: 大将
  • 技术积分: 5485
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-20 17:36
文章分类

全部博文(836)

文章存档

2011年(1)

2008年(835)

我的朋友

分类: LINUX

2008-08-20 18:18:24


1cat/etc/shells 查看计算机上可用的shell 2编写shell,保存为firstscript
#!/bin/bash

#Thisisatest.

echo-nYourcurrentdirectoryis:

pwd

echo$HOME

echoYourcurrentdirectoryis:

pwd

#END.
3运行firstscript $/bin/bashfirstscript 如果找不到文件使用pwd查看当前目录 $/bin/bashpwd/firstscript 可见当前运行结果。 4可以修改firstscript为执行 $chmoda xfirstscript 此时输入$./firstscript即可 上面的shell没有交换,我们可以进行交互,如下:
#!/bin/sh

echo-nPleaseinputyourID:

readid_var

echo-nPleaseinputyourpassword:

readpassword

echoUserID=$id_var

echopassword=$password

if[$password="admin"];then

echo"passwordisright"

else

echo"passwordiswrong"

fi
同前面的运行,自己测试。 (责任编辑:云子)


下载本文示例代码
阅读(287) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~