LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1170|回复: 2

当在终端下提示要输入密码时,可否用shell来自动完成?

[复制链接]
发表于 2006-4-6 21:05:34 | 显示全部楼层 |阅读模式
我需要通过一个程序(serctl)向mysql数据库中添加记录.
此程序实际是以一个已经存在于mysql中的名为ser的用户的身份来执行的,
所以系统会提示要求输入该ser用户的密码.

[lex@localhost]$ serctl add user3 123456 user3@email.com
MySql password:(这里要求ser的密码)
new user added
new user into uri table added
[lex@localhost]$

现在我需要添加很多用户,但不希望每次都手动输入密码。

我的问题是,可否通过shell编程来达到这个目的?

谢谢大家
发表于 2006-4-6 23:39:22 | 显示全部楼层
programs such as su, passwd, ssh, etc only accept input from real tty devices, shell can't program on that. you basically need something can simulate tty input such as expect.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-4-7 02:32:54 | 显示全部楼层
谢谢,看来之好想其他办法了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表