Linux 期望命令
我正在使用 linux 'expect' 来自动化密码。
#!/usr/bin/expect
set password passwd
spawn scp * root@ip_address:.
expect "password:"
send "$password\r"
expect eof
output :
spawn scp * root@ip_address:.
root@ip_address's password: *: No such file or directory
看起来正则表达式“*”无法识别。我知道 ssh-key gen 方法来设置密钥,但“expect”命令更适合我的具体情况。
I am using the linux 'expect' to automate passwords.
#!/usr/bin/expect
set password passwd
spawn scp * root@ip_address:.
expect "password:"
send "$password\r"
expect eof
output :
spawn scp * root@ip_address:.
root@ip_address's password: *: No such file or directory
Looks like the regular expression '*' is not recognized. I know of the ssh-key gen method to set up keys but 'expect' command is more suitable for my specific case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
*
不是有效的正则表达式,在您使用它的上下文中,它将是一个通配符。spawn
将从字面上解释它,并将其作为参数传递给您正在启动的程序。如果你想要星号通配符,你必须有一个 shell 来为你做这件事:
*
is not a valid regular expression, and in the context you're using it, it would be a wildcard. Thespawn
will interpret it literally and pass it as an argument to the program you're starting.If you want the asterisk globbed, you'll have to get a shell to do it for you: