我想要做的事,如:schroot:傳遞一個要執行的命令,如果它是在一個殼
schroot -c name -u root "export A=3 && export B=4"
,但我得到的錯誤:
Failed to execute 「export」: No such file or directory
換句話說,我想能夠以編程方式在schroot環境中執行shell命令。什麼是正確的方式來獲得這種行爲?
我想要做的事,如:schroot:傳遞一個要執行的命令,如果它是在一個殼
schroot -c name -u root "export A=3 && export B=4"
,但我得到的錯誤:
Failed to execute 「export」: No such file or directory
換句話說,我想能夠以編程方式在schroot環境中執行shell命令。什麼是正確的方式來獲得這種行爲?
我建議:
schroot -c name -u root sh -c "export A=3 && export B=4"
這將運行與 '-c' 選項殼告訴它( shell)讀取以下參數作爲要執行的命令(腳本)。相同的技術與其他類似命令一起工作:'su','nohup',...
你可以嘗試
schroot -c name -u root "/bin/bash -c 'export A=3; export B=4'"
,但是這是第一次聽說schroot的。導出看起來像是無用的......即使直接從命令行運行雙引號的東西,似乎子shell不想影響父母的環境。
我認爲如果你使用'schroot -c name -u root/bin/bash -c'export A = 3,那麼對於更復雜的命令,引用會更好。代之以導出B = 4''。 – Omnifarious 2010-06-19 06:04:22
可能。但就像我說過的,我從來沒有見過斯諾根之前。我不確定命令是否必須是一個字符串或什麼。 – cHao 2010-06-19 06:07:11
schroot -c name -u root -- export A=3 && export B=4
確保/etc/schroot/schroot.conf具有
run-exec-scripts=true
run-setup-scripts=true
我想也許這個問題屬於ServerFault,而不是StackOverflow。 – Omnifarious 2010-06-19 05:55:20