使用脚本输入密码。重击&| Python

问题描述 投票:-1回答:1

我正在尝试创建一个脚本来在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/

方法

python bash echo webdav
1个回答
0
投票

带有Here document

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

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

© www.soinside.com 2019 - 2024. All rights reserved.