쉘 스크립트 내에서 su -c "cmd arg"및 tomcat이 작동하는 방식이 궁금합니다. cmd를 라인에서쉘 스크립트에서 catalina를 사용하여 tomcat을 시작할 수없는 이유는 무엇입니까?
수동으로, 나는 달렸다 :이 작동하지 않았다
su -m tomcat -c /path/to/tomcat/catalina.sh start
.
이START="/path/catalina.sh start"
...
...
su -m tomcat -c "$START"
명령은 다음과 같습니다 제가 따옴표로 cmd를 넣어 경우, 그것은, 내가 이런 일이 (가 자동으로 시작되도록 chkconfig를 실행하려고) 쉘 스크립트 내에서
su -m tomcat -c "/path/catalina.sh start"
근무 따옴표 안에 나는 따옴표가 필요하다는 것을 수동으로 발견했기 때문에.
Using CATALINA_BASE: /apps/local/apache-tomcat-7.0.42
Using CATALINA_HOME: /apps/local/apache-tomcat-7.0.42
Using CATALINA_TMPDIR: /apps/local/apache-tomcat-7.0.42/temp
Using JRE_HOME: /usr/java/default
Using CLASSPATH: /apps/local/apache-tomcat-7.0.42/bin/bootstrap.jar:/apps/local/apache-tomcat-7.0.42/bin/tomcat-juli.jar
Usage: catalina.sh (commands ...)
commands:
debug Start Catalina in a debugger
debug -security Debug Catalina with a security manager
jpda start Start Catalina under JPDA debugger
run Start Catalina in the current window
run -security Start in the current window with security manager
start Start Catalina in a separate window
start -security Start in a separate window with security manager
stop Stop Catalina, waiting up to 5 seconds for the process to end
stop n Stop Catalina, waiting up to n seconds for the process to end
stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
configtest Run a basic syntax check on server.xml - check exit code for result
version What version of tomcat are you running?
Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined
이 출력 내가 수동으로 시작/O를 인수를 중단 승/catalina.sh를 실행 한 경우처럼 : 나는 스크립트를 실행하면 는, 출력은 다시로 제공됩니다.
쉘 스크립트에서 시작/중지 옵션이 무시되는 이유는 무엇입니까? 예, catalina.sh를 startup.sh 및 shutdown.sh로 대체했으며 스크립트가 작동하도록 만들었지 만 여전히 스크립트 내부에서 su -c "cmd arg"가 명령의 인수 부분을 무시하는 것처럼 보였습니다.
미리 감사드립니다. 만약 내가 따옴표를 잃지 않도록하기 위해 뭔가를하지 않으면 쉘 확장과 따옴표 제거만큼 쉬운 일이라면 나는 스스로를 쏠 것이다.
나는이 현상이 Tomcat이나 catalina.sh 스크립트와 관련이 있다고 생각하지 않는다. 'su' 매뉴얼 페이지를 보면'-c' 다음에 _single 명령어가 나온다. 어쩌면 이것은 바로 다음 매개 변수 만 명령으로 해석 될 수 있으며 잠재적으로 매개 변수를 따르지 않는다고 말하는 개발자의 태도는 어딘지 모릅니다. 이 점에서 이는 예를 들어, 'ssh' 또는'rsh' 명령으로 쉘 호출의 모든 매개 변수를 실행할 명령의 매개 변수로 해석합니다. 따옴표 만 있으면됩니다. –