通过scp 将本地的sh文件上传到了 远程计算机
通过vim查看文件内容也没错 在本地运行也没错
但是在ssh连接远程计算机后,运行a.sh
提示command not found。。。。
[coffee@localhost stress]$ ls
stress-test-0.0.1-SNAPSHOT.jar stress-test-thread.sh
stress-test-2015-05-13.log stress-test-time.sh
[coffee@localhost stress]$ stress-test-thread.sh 100 check
-bash: stress-test-thread.sh: command not found
怎么回事啊?
谢谢
腳本直接執行需要有可執行權限:
使用ls -lrt看看,是否有可執行權限,沒有的話加上:chmod +x stress-test-thread.sh
你使用a.sh執行的方式是會到全域path中搜尋a.sh這個可執行文件,你的當前path不再全域path的環境變數中是找不到的,就會報command not found;
幾個解決方法:
1)使用./a.sh的方式執行本目錄下的可執行檔;
2)將目前目錄加入全域path環境變數中,或將a.sh加入/bin/這樣的全域path(or加在這類path加上符號連結)
腳本沒有可執行權限的情況可以使用以下方式執行:
source a.sh
. a.sh
你需要將
stress-test-thread.sh
的mode
改為可執行的.