簡體   English   中英

運行帶有 su 錯誤的 shell 腳本

[英]Run shell script with su errors

我有一個由 root 運行的腳本,看起來像這樣

curl -O some stuff
mv it to user guest directory
su - guest -c sh /home/guest/script.sh

一切正常,直到最后一個su命令。 它給了我錯誤

sh: cannot set terminal process group (-1): inappropriate ioctl for device
sh: no job control in this shell

如何讓用戶guest使用su執行script.sh

來自man su

概要
su [選項] [-] [用戶[參數...]]

您更改了參數的順序。 試試這個方法:

su -c "/path/to/sh /home/guest/script.sh" - guest

注意命令開始之前和結束之后的引號" 。此外,我建議您也對sh使用絕對路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM