1
java 프로그램을 사용하여 쉘 스크립트를 실행하려고합니다. 나는 예외를 겪고있다.Java 프로그램에서 쉘 스크립트를 실행할 때 사용 권한이 거부되었습니다.
java.io.IOException: Cannot run program "/home/builder/code/target/classes/idFetcher.sh": java.io.IOException: error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:605)
at java.lang.Runtime.exec(Runtime.java:443)
at java.lang.Runtime.exec(Runtime.java:340)
at script.InformationFetcher.main(InformationFetcher.java:26)
파일 경로가 정확하며 해당 위치에 파일이 있습니다. 여기
package script;
import java.io.IOException;
public class InformationFetcher {
public InformationFetcher() {
}
public static void main(String[] args) {
try {
InformationFetcher informationFetcher = new InformationFetcher();
Runtime.getRuntime().exec(informationFetcher.getFilePath());
} catch (IOException e) {
e.printStackTrace();
}
}
public String getFilePath() {
return this.getClass().getResource("/idFetcher.sh").getPath();
}
}
의 쉘 스크립트를 실행하십시오 내 코드입니다. 나는 비슷한 문제가 있다고 생각한다. http://stackoverflow.com/questions/14684713/java-calling-bash-script-permission-denied-error – Maddy
쉘 스크립트에 owner, group 및 global에 대한 올바른 실행 권한이 있는지 확인하십시오. – SpartanElite
chmod + x가 도움이 될 수 있습니다 ... – Debasis