2017-04-27 19 views
1

我使用下面的方法讀取文件通過一個腳本,並在myarray的IFS讀沒有得到在linux

while IFS=$'\t' read -r -a myArray do "do something" done < file.txt echo "ALL DONE"

現在存儲在「做什麼」區域中使用的命令通過遠程當執行完畢我使用的一些命令通過ssh

ssh [email protected]$SERVER "some command"

但問題是執行該file.txt的一號線後,腳本將停止讀取文件進一步並跳至下一個步驟就是我GE t爲輸出但

ALL DONE

,而不是通過SSH命令我使用的腳本文件運行本地命令。我不知道爲什麼會發生這種情況。有人可以建議我需要做什麼?

回答

0

你必須嘗試給-n標誌SSH,從manpage

-n  Redirects stdin from /dev/null (actually, prevents reading from 
      stdin). This must be used when ssh is run in the background. A 
      common trick is to use this to run X11 programs on a remote 
      machine. For example, ssh -n shadows.cs.hut.fi emacs & will 
      start an emacs on shadows.cs.hut.fi, and the X11 connection will 
      be automatically forwarded over an encrypted channel. The ssh 
      program will be put in the background. (This does not work if 
      ssh needs to ask for a password or passphrase; see also the -f 
      option.) 
+0

感謝@PW。有效。 –