
我有一個 shell 腳本,使用以下命令以 root 身份運行:
ssh remotehost 'su - user sh -c "source /home/user/.profile; <command>"'
我得到以下輸出:
bash: su - user sh -c "source /home/user/.profile; <command>": 沒有這樣的檔案或目錄。
不過, /home/user/.profile 肯定存在於遠端主機上。這是怎麼回事?還有其他方法可以匯入 .profile 中定義的路徑嗎?