2010-12-10 8 views
0

나는 파일을 만든 :파일을 쉘 스크립트로 만들고 실행하는 방법은 무엇입니까?

tinymce_compressor.sh 
$chmod +x tinymce_compressor.sh 
$ tinymce_compressor 
-bash: tinymce_compressor: command not found 
내가 터미널이 쉘 스크립트를 실행할 수있는 방법

?

여기에 전체 스크립트입니다 :

#!/bin/sh 
# Tinymce compressor shell script 
# 
# This program is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation; version 2 of the License. 
# 
# 
# This program is distributed in the hope that it will be useful, 
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
# GNU General Public License for more details. 
#   
# (C) Copyright 2010 Gabor Vitez 
# 
# 
# Concatenates the tinymce components into a single static file 
# Can be used with any web server which can serve static files 
# Note you have to re-run this script every time you upgrade tinymce, 
# or change the required modules 
# 
# Usage: upon every invocation, the scipt will create a new 
# "tinymceappended.js" file, which contains the requested components 
# 
# In your html pages you have to change 
# 
# <script type="text/javascript" src="<your installation path>/tiny_mce/tiny_mce.js"></script> 
# 
# to 
# 
# <script type="text/javascript" src="<your compressed tinymce url>/tinymceappended.js"> </script> 
# 


#config section 
#where does tinymce live in the filesystem? 
BASE="/Users/xxxx/Sites/cline/public/javascripts/tiny_mce/" 
#under which URLs do the original tinymce components show up? 
URLBASE="/tinymce" 
#just as in the javascript config section 
THEMES="advanced" 
PLUGINS="safari spellchecker pagebreak style layer save advhr advimage advlink emotions iespell inlinepopups insertdatetime preview media searchreplace contextmenu paste directionality fullscreen noneditable visualchars nonbreaking xhtmlxtras" 
LANGUAGES="en" 
#end config section 

(
LOADED="" 
cd $BASE || exit 1 
#cat tiny_mce.js 
sed "s/tinymce._init();/tinymce.baseURL='\/tinymce';tinymce._init();/"<tiny_mce.js 
#echo "tinyMCE_GZ.start();" 
#cat tiny_mce_popup.js && LOADED="$LOADED $URLBASE/tiny_mce_popup.js" 
for lang in $LANGUAGES 
     do 
       cat langs/$lang.js && LOADED="$LOADED $URLBASE/langs/$lang.js" 
     done 
for theme in $THEMES 
     do 
       cat themes/$theme/editor_template.js && LOADED="$LOADED $URLBASE/themes/$theme/editor_template.js" 
       for lang in $LANGUAGES 
         do 
           cat themes/$theme/langs/$lang.js && LOADED="$LOADED $URLBASE/themes/$theme/langs/$lang.js" 
         done 

     done 

for plugin in $PLUGINS 
     do 
       cat plugins/$plugin/editor_plugin.js && LOADED="$LOADED $URLBASE/plugins/$plugin/editor_plugin.js" 
       for lang in $LANGUAGES 
         do 
           cat plugins/$plugin/langs/$lang.js && LOADED="$LOADED $URLBASE/plugins/$plugin/langs/$lang.js" 
         done 

     done 
echo 
#echo $LOADED >&2 
for i in $LOADED 
     do 
       echo "tinymce.ScriptLoader.markDone(tinyMCE.baseURI.toAbsolute(\"$i\"));" 
     done 
#echo "tinyMCE_GZ.end();" 
) >tinymceappended.js 

감사 기본적으로

+0

어쩌면 ./tinymce_compressor.sh? 그러나 나는 전혀 모르겠다. ... – BlackBear

+0

나는 이것이 주제에 관한 것인가에 관해서 울타리에있다. 그것은 [Unix and Linux] (http://unix.stackexchange.com/)와 아마도 [SU] (http://superuser.com/)에 적합합니다. –

답변

2

당신은 당신이 실행 파일은 확장자없이 호출하고 현재 디렉토리가 PATH 항상 할 수있는 Windows에서 온 것으로 보인다

$ ./tinymce_compressor.sh 

전화를 만들었습니다.

1

현재 디렉토리 경로에없는; 당신은 스크립트가 현재 폴더 (.)에 있음을 지정해야합니다

./tinymce_compressor.sh 
2

스크립트는 현재 디렉토리에 있지만, 쉘이 시도하고 명령을 찾기 위해 사용하는 것이다 (경로에하지 않은 실행). 따라서

./tinymce_compressor.sh 

트릭을 수행해야합니다. 명령 검색 경로에 대한 자세한 내용과 현재 경로 (일명 ".")를 경로에 포함시키는 것이 좋지 않은 이유는 유닉스 자주 묻는 질문 목록에서 "What's wrong with having '.' in your $PATH ? "을 참조하십시오 ..

관련 문제