Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从另一个bash脚本使用sudo运行bash脚本_Bash_Sudo - Fatal编程技术网

如何从另一个bash脚本使用sudo运行bash脚本

如何从另一个bash脚本使用sudo运行bash脚本,bash,sudo,Bash,Sudo,我正在尝试从脚本b运行脚本a,我没有创建脚本a,我不确定是否要将脚本as位置添加到路径 让事情变得更难做的是,我想用sudo运行scripta,而不是scriptb,所以我在scriptb中有whiptail来请求密码并随echo$pass | sudo-S一起传递 我当前的代码: #!/bin/bash input=$(whiptail --passwordbox "Enter password" 10 50 3>&1 1>&2 2>&3 ) echo

我正在尝试从脚本
b
运行脚本
a
,我没有创建脚本
a
,我不确定是否要将脚本
a
s位置添加到
路径

让事情变得更难做的是,我想用sudo运行script
a
,而不是script
b
,所以我在script
b
中有
whiptail
来请求密码并随
echo$pass | sudo-S
一起传递

我当前的代码:

#!/bin/bash
input=$(whiptail --passwordbox "Enter password" 10 50 3>&1 1>&2 2>&3 )
echo $input | sudo -S bash /home/<username>/multibootusb/makeUSB.sh -e -b "$1" "$2"
#/bin/bash
输入=$(whiptail--密码框“输入密码”10503>&11>&22>&3)
echo$input | sudo-sbash/home//multibootusb/makeUSB.sh-e-b“$1”“$2”

一切看起来都很好,怎么了?)另请参见(提示:这是其中一种情况)。您可以使用
read
而不是
whiptail
像这样
read-s-p'Enter password'输入
为什么自己提示输入密码<如果需要密码,code>sudo
将提示输入密码。@Ivan。它不起作用。sudo说它找不到它