2017-09-05 138 views
1

爲什麼我無法在遠程主機上執行命令。 我錯過了什麼嗎?命令not found.when在遠程主機上執行bash時

猛砸文件:hello.sh

#!/bin/sh 
host_name="myHost" 
ssh $host_name ' 
STR="Hello World!" 
echo $STR 
' 

executing above file: the print out: 
> ./print_node_status.sh 
Enter Windows password: 
STR=Hello World!: Command not found. 
STR: Undefined variable. 
+0

不確定爲什麼該提示要求輸入「Windows密碼」。無論如何,我會假設它是一個linux節點。 –

回答

1

它看起來像你的遙控器外殼是the C shell,而不是猛砸。

您有幾種選擇:

  • 適應您的代碼以符合shell的語言:

ssh $host_name ' 
    set STR="Hello World\!" 
    echo $STR 
    ' 
  • 在遠程過程執行/bin/bash,如果它是可用的,例如:

ssh $host_name ' 
    exec /bin/bash 
    STR="Hello World!" 
    echo $STR 
    ' 
  • 更改該節點上的用戶的默認外殼/bin/bash,看到chsh(1)手冊頁。