Chinaunix首页 | 论坛 | 博客
  • 博客访问: 330892
  • 博文数量: 30
  • 博客积分: 3021
  • 博客等级: 少校
  • 技术积分: 408
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-01 11:32
文章分类

全部博文(30)

文章存档

2022年(1)

2015年(2)

2014年(1)

2013年(1)

2012年(2)

2011年(2)

2010年(3)

2009年(10)

2008年(8)

分类: Oracle

2011-09-07 16:44:57

平时对一些小的数据导出的时候,都得写一条长长的exp命令,此脚本目的就是为了简化日常的重复输入,提高效率,实现起来很简单,具体如下:
daochu.sh
  1. #!/bin/sh
  2. if [ $# -ne 1 ]; then
  3. echo "Usage: $0 Username"
  4. exit 101
  5. fi
  6. username=$1
  7. echo "please input your password"
  8. stty -echo
  9. read password
  10. stty echo
  11. #echo "Your password is: $password"
  12. filepath=`date +%y%m%d_%H%M%S`_$username
  13. mkdir $filepath
  14. exp $username/$password file=$filepath/$username.dmp log=$filepath/"$username"_exp.log
  15. cd $filepath
  16. md5sum $username.dmp>$username.dmp.md5
语法为daochu.sh username
密码不显示,文件名以日期+导出用户名命名,并计算md5值。
上述密码输入在使用时也可以借鉴网上的一个转*的shell,将输入的密码以*号展现,转*的shell如下:
  1. ##automatically convert the input characters to *##
  2. getchar() {
  3. stty cbreak -echo
  4. dd if=/dev/tty bs=1 count=1 2> /dev/null
  5. stty -cbreak echo
  6. }

  7. printf "Please input your password: "

  8. while : ; do
  9. ret=`getchar`
  10. if [ x$ret = x ]; then
  11. echo
  12. break
  13. fi
  14. password="$password$ret"
  15. printf "*"
  16. done
  17. ######################################################
功能很简单,应该比较实用。
阅读(1300) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~