linux - 运行通过ssh连接的远程计算机上的sh文件和运行本地的一样么?
天蓬老师
天蓬老师 2017-04-17 13:17:01
0
2
409

通过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
怎么回事啊?
谢谢

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回覆(2)
洪涛
  1. 腳本直接執行需要有可執行權限:
    使用ls -lrt看看,是否有可執行權限,沒有的話加上:chmod +x stress-test-thread.sh

  2. 你使用a.sh執行的方式是會到全域path中搜尋a.sh這個可執行文件,你的當前path不再全域path的環境變數中是找不到的,就會報command not found;
    幾個解決方法:
    1)使用./a.sh的方式執行本目錄下的可執行檔;
    2)將目前目錄加入全域path環境變數中,或將a.sh加入/bin/這樣的全域path(or加在這類path加上符號連結)

  3. 腳本沒有可執行權限的情況可以使用以下方式執行:
    source a.sh
    . a.sh

黄舟

你需要將stress-test-thread.shmode改為可執行的.

$ chmod +x stress-test-thread.sh
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!