我正面临一个脚本的问题,该脚本读取文件并运行sudo su命令

时间:2017-05-09 13:00:16

标签: linux shell unix ksh

我收到了这个错误

stty: standard input: Invalid argument

当我运行一个包含以下命令的shell脚本时:

sudo su - <name>

示例:

cat file.txt | while read line
do
echo $line
sudo su - $line
exit
done

文件file.txt - 仅包含用户名。

我有管理员权限,所以这不是问题。

2 个答案:

答案 0 :(得分:0)

如果您正在向用户执行sudo,则必须返回到运行该脚本的当前用户。

答案 1 :(得分:0)

您只需提供// ALWAYS ALWAYS ALWAYS sanitize your input. Use prepared statements to // build safe queries (see first comment under this answer). This example // of using msqli_escape_string is NOT considered "secure", but is used in // this context to highlight the importance of sanitization. $product_categories1 = msqli_escape_string($product_categories1); if ($var == 'condition') { $condition = "agentid IS NOT NULL"; } else { $condition = "agentid IS NULL"; } $sql = "SELECT * FROM suppliers WHERE product_categories LIKE '%$product_categories1%' AND $condition"; 的用户名:

sudo