+ -
当前位置:首页 → 问答吧 → 用expect写的mysql登录脚本,为什么无效?

用expect写的mysql登录脚本,为什么无效?

时间:2011-07-25

来源:互联网

  1. #!/usr/bin/expect
  2. set timeout 30
  3. spawn mysql -uroot -p
  4. expect "Enter password:"
  5. send "123456"
  6. interact
复制代码
spawn mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

感觉是-p参数没有生效。

作者: xinglu1983   发布时间: 2011-07-25

找到原因了,是我粗心了,密码后面没有加回车符。

send "123456\r"

作者: xinglu1983   发布时间: 2011-07-25

热门下载

更多