【问题标题】:use a script to enter a password. Bash &| Python使用脚本输入密码。重击和| Python
【发布时间】:2020-04-28 17:20:25
【问题描述】:

我正在尝试创建一个脚本来在 Linux 中挂载一系列 webDAV 文件夹。

现在这在执行时是可能的:

sudo mount -t davfs  -o  noexec http://dav.website.com /mnt/

问题是,一旦执行命令,就会要求用户输入凭据...

enter username:
enter password:

现在我对整个系列的在线 DAV 文件夹都有相同的密码和用户名

有没有办法让我编写一个 bash 或 bash 嵌入式 python 脚本?

我已经尝试了以下

sudo mount -t davfs  -o  noexec http://dav.website.com /mnt/ |echo username\npassowrd

,但没有成功。

我真的要使用

sudo mount -t davfs  -o  noexec http://dav.website.com /mnt/

方法。

【问题讨论】:

  • 看看expect,它是为这类事情而生的。

标签: python bash echo webdav


【解决方案1】:

Here document:

sudo mount -t davfs -o noexec http://dav.website.com /mnt/ << EOF
username
password
EOF

为了提高安全性,请使用file for credentials

【讨论】:

    猜你喜欢
    • 2019-11-02
    • 2012-08-25
    • 2010-09-18
    • 2015-11-03
    • 2021-05-04
    • 2010-11-24
    • 2012-11-18
    相关资源
    最近更新 更多