試圖運行一個簡單的shell腳本,其中包含我經常執行的一組命令來設置我的Hadoop環境。首先,我通過'ssh localhost'連接,然後手動執行這些命令,我想自動執行此過程,我正在執行以下操作,這會導致下面列出的錯誤。請注意我可以通過命令提示符手動執行這些命令。請幫助我。運行簡單shell腳本時出錯
我做什麼
$sudo chmod 777 hadoop-startup-script.sh
$ssh localhost
$./hadoop-startup-script.sh
這將導致以下錯誤
(~($))sh hadoop-startup-script.sh
hadoop-startup-script.sh: 2: cd: can't cd to /home/hadoop/hadoop-0.20.204.0
hadoop-startup-script.sh: 3: hadoop-startup.sh: bin/hadoop: not found
hadoop-startup-script.sh: 4: hadoop-startup.sh: bin/start-all.sh: not found
hadoop-startup-script.sh: 5: hadoop-startup.sh: bin/hadoop: not found
hadoop-startup-script.sh: 6: hadoop-startup.sh: bin/hadoop: not found
hadoop-startup-script.sh: 7: hadoop-startup.sh: bin/hadoop: not found
hadoop-startup-script.sh: 8: hadoop-startup.sh: bin/hadoop: not found
hadoop-startup-script.sh: 9: hadoop-startup.sh: bin/hadoop: not found
hadoop-startup-script.sh: 10: hadoop-startup.sh: bin/hadoop: not found
的hadoop-startup-script.sh
#! /bin/bash
cd ~/hadoop-0.20.204.0
bin/hadoop namenode -format
bin/start-all.sh
bin/hadoop fs -mkdir input
bin/hadoop fs -mkdir input/oreilly
bin/hadoop fs -put /home/hadoop/Dropbox/hadoop/hadoop-inputs/oreilly-programmingPig/*.* /user/hadoop/input/oreilly/
bin/hadoop fs -put /home/hadoop/Dropbox/hadoop/hadoop-inputs/oreilly-programmingPig/NYSE_dividends /user/hadoop/input/oreilly/
bin/hadoop fs -put /home/hadoop/Dropbox/hadoop/hadoop-inputs/oreilly-programmingPig/baseball /user/hadoop/input/oreilly/
bin/hadoop fs -put /home/hadoop/Dropbox/hadoop/hadoop-inputs/oreilly-programmingPig/NYSE_daily /user/hadoop/input/oreilly/
那麼你的問題是什麼? – Gumbo
第一個錯誤是重要的錯誤,其他所有錯誤都是從其中獲得的,因爲您從未到達其他命令可以工作的文件夾。也許檢查該文件夾的權限? – wilks
是否存在'〜/ hadoop-0.20.204.0'?運行'ls -l〜/ hadoop-0.20.204.0'。 – Ross