2012-01-03 4 views
1

내 다음 스크립트는 그것에 대해 '다음'파일 종료 전에 키워드가. 내가 오류를 찾을 수 없습니다 기대 불평 (에러를 생산하고있다. 당신은 시간이 있으면 도와주세요.bash 스크립트가 EOF 오류 후 올바르게 종료되지 않습니다 (예상).

것은, 감사 유카

스크립트가 작동
#!/bin/sh 
#Makes the /usr/lib/jvm in case... 
sudo mkdir -p /usr/lib/jvm; 
sudo mkdir /org-thejarbar-work-dir; 
cd /org-thejarbar-work-dir; 

#Update this line to reflect newer versions of JDK... 
wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.tar.gz; 

#Extract the download 
tar -xvf ./*gz; 

#Move it to where it can be found... 
sudo mv ./* /usr/lib/jvm/; 
sudo ln -s /usr/lib/jvm/jdk1*/bin/java /usr/bin/; 
sudo rm -rf /org-thejarbar-work-dir; 

#Makes the /usr/lib/maven in case... 
sudo mkdir -p /usr/lib/maven; 
sudo mkdir /org-thejarbar-work-dir; 
cd /org-thejarbar-work-dir; 

#Update this line to reflect newer versions of maven 
wget http://mirrors.powertech.no/www.apache.org/dist//maven/binaries/apache-maven-3.0.3-bin.tar.gz; 
tar -xvf ./*gz; 

#Move it to a more logical location 
sudo mv ./* /usr/lib/maven/; 

#If you have Maven on Windows and use VirtualBox, you can set up the maven to be a virtualbox shared folder. 
#The name must match the name used below (ignore if irrelevant to you). 
sudo mount -t vboxsf maven /usr/lib/maven; 

#Link the new Maven to the bin... 
sudo ln -s /usr/lib/maven/apache-maven-*/bin/mvn /usr/bin/; 
sudo rm -rf /org-thejarbar-work-dir; 
sudo mkdir /org-thejarbar-work-dir; 
cd /org-thejarbar-work-dir; 

#Update this line to reflect newer versions of Netbeans or replace 'javase' with 'javaee' or add Java EE manually via 
#Netbeans 'plugins as needed. 
wget http://download.netbeans.org/netbeans/7.0.1/final/bundles/netbeans-7.0.1-ml-javase-linux.sh; 
sh //*sh; 
sudo mv ./* /usr/lib/ide/; 

#Add Netbeans launcher to your PATH. Doing so allows you to run 'netbeans' command from the terminal 
sudo ln -s /usr/lib/ide/netbeans-7*/bin/netbeans /usr/bin/; 

#If you use VirtualBox , you can share your projects between Host and guest. Name of shared 
#folder must match 'NetBeansProjects' Remove this if you don't need... 
if [ ! -d "~/NetBeansProjects" ]; then 
    sudo mkdir ~/NetBeansProjects; 
fi 

sudo mount -t vboxsf NetBeansProjects ~/NetBeansProjects; 
sudo rm -rf /org-thejarbar-work-dir; 
sudo mkdir /org-thejarbar-work-dir; 
cd /org-thejarbar-work-dir; 

#Update this line to reflect newer versions of Netbeans or replace 'javase' with 'javaee' or add Java EE manually via 
#Netbeans 'plugins as needed. 
wget http://download.netbeans.org/netbeans/7.0.1/final/bundles/netbeans-7.0.1-ml-javase-linux.sh; 
sh //*sh; 
sudo mv ./* /usr/lib/ide/; 

#Add Netbeans launcher to your PATH. Doing so allows you to run 'netbeans' command from the terminal 
sudo ln -s /usr/lib/ide/netbeans-7*/bin/netbeans /usr/bin/; 

#If you use VirtualBox , you can share your projects between Host and guest. Name of shared 
#folder must match 'NetBeansProjects' Remove this if you don't need... 
if [ ! -d "~/NetBeansProjects" ]; then 
    sudo mkdir ~/NetBeansProjects; 
fi 

sudo mount -t vboxsf NetBeansProjects ~/NetBeansProjects; 
sudo rm -rf /org-thejarbar-work-dir; 
sudo mkdir /org-thejarbar-work-dir; 
cd /org-thejarbar-work-dir; 
sudo wget http://download-ln.jetbrains.com/idea/ideaIC-11.tar.gz 
sudo tar -zxvf ./*.gz; 

#Move it to a better location... 
sudo rm -rf /usr/lib/ide/idea-IC*; 
sudo mv ./* /usr/lib/ide/; 

#Add IDEA launcher to your PATH. Doing so allows you to run 'idea.sh' command from the terminal 
rm /usr/bin/idea.sh; 
sudo ln -s /usr/lib/ide/idea-IC*/bin/idea.sh /usr/bin/; 

#If you use VirtualBox , you can share your projects between Host and guest. Name of shared 
#folder must match 'IdeaProjects' Remove this if you don't need... 
if [ ! -d "~/IdeaProjects" ]; then 
    sudo mkdir ~/IdeaProjects; 
fi 

sudo rm -rf /org-thejarbar-work-dir; 

exit 0; 

주 (필요한 것을 않습니다)하지만 오류가. 내가 오류를 방지하기 위해 노력하고 내가 다른 사람에게이 스크립트를 공유 일하고으로 귀찮은입니다. 모든

+1

쉘을 게시 할 수 있습니까 (예 :'ls -l/bin/sh'의 출력)? 스크립트가 내 컴퓨터에서 제대로 작동하는 것 같습니다. – phihag

+1

이것은 문제를 해결하지 않지만 ";" 각 명령 줄의 끝에서 필요하지 않습니다. 동일한 행에서 여러 명령을 실행하려는 경우에 사용됩니다. 나는 코드를 작성한 직후에 특히 잘하고있다. – Rob

+0

@phihag 출력 : yucca-VirtualBox : ~ $ ls -l/bin/sh lrwxrwxrwx 1 루트 루트 4 2011-12-12 09:47/bin/sh -> 대시 – thejartender

답변

3

먼저, 그건 지금은 bash 스크립트가 아닙니다. bourne 쉘 스크립트입니다. bash를 사용하려면 fir을 변경하십시오. st line ("shebang")은 /bin/bash을 사용합니다. 귀하의 의견에 따르면 /bin/sh은 실제로 시스템에 dash입니다. dash는 bourne 쉘의 최소 구현입니다.

-x과 같이 실행하면 bash 스크립트를 디버그 할 수 있습니다. /bin/bash -x script.sh; 또는 shebang을 #!/bin/bash -x (일시적)으로 변경하십시오.

제쳐두고, 디렉토리를 테스트하고 존재하지 않는 디렉토리를 생성합니다. if 절 안에서 수행 할 작업이 모두있는 경우 일반 경로 mkdir -p을 사용할 수 있으므로 경로가 이미 존재하면 오류가 발생하지 않습니다. 모든 * nix 시스템에서 사용할 수있는 것은 아니지만 GNU/Linux에 있음을 유의하십시오.

+0

bour보다 bash를 권장 하시겠습니까? Mac 이외의 유닉스만을 목표로하고 있습니까? – thejartender

+0

Solaris, AIX 및 HP/UX와 같은 것을 목표로 삼고 있다면 반드시 본을 고수하십시오. 제 의견으로는 의심 할 여지없이 bash 기능이 당신의 삶을 편하게 해줄 수 없다면 bourne을 계속 사용하십시오. ''-x''도 bourne과 함께 사용할 수 있습니다. –

+0

Bourne은 더 널리 사용 가능하지만 이식성 있고 견고하게 작성하기가 더 어렵습니다. 대상 플랫폼이 Linux 인 경우 Bash를 요구하는 것이 타당합니다 (단,이 요구 사항을 문서화하십시오). – tripleee

1

sh //*sh;을 확인하고 일치하는 스크립트가 있으면 확인하십시오. 이 줄은 / 경로 아래에있는 sh에서 끝나는 모든 스크립트와 기본적으로 일치하며 실행됩니다.

관련 문제