开发者社区> 问答> 正文

linux 怎么在不用鼠标的情况下在tty上复制文字?

linux 怎么在不用鼠标的情况下在tty上复制文字?

Update
场景是这样的:

我登陆tty1 ,ssh到另一台机器,在另一台机器上,执行sudo需要输入密码.我把密码保存在tty1上的alias为pass的命令里面 。现在我可以通过pass拿到密码,但是密码太长了,不能一个字一个字的打上去啊..

展开
收起
a123456678 2016-06-23 15:20:13 3389 0
1 条回答
写回答
取消 提交回答
  • 你可以采用一些变通的办法来实现,比如使用:expect

    #!/usr/bin/expect -f
    set timeout 30
    spawn ssh -l user1_name xxx.xxx.xxx.xxx
    expect "password:"
    send "user1_password\r"
    expect "user1"
    send "su\r"
    expect "password:"
    send "root_password\r"
    首先使用user1_name登录xxx.xxx.xxx.xxx
    等待出现password文字,send“user1密码”
    等待登录成功后的user1,send“su”
    然后再等待提示password,send“root密码”
    2019-07-17 19:46:24
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Alibaba Cloud Linux 3 发布 立即下载
ECS系统指南之Linux系统诊断 立即下载
ECS运维指南 之 Linux系统诊断 立即下载