티스토리 뷰
반응형
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) throws Exception {
String command = "ls -al";
shellCmd(command);
}
public static void shellCmd(String command) throws Exception {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(command);
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
}
// java에서 리눅스 명령어 실행
반응형
'Study' 카테고리의 다른 글
MySQL(마이에스큐엘) 관련 (1) | 2024.03.15 |
---|---|
DB(디비) Tool(도구) 관련 (0) | 2024.03.15 |
Hash(해시) 관련 (0) | 2024.02.18 |
Apache(아파치) Install(설치) (0) | 2024.02.18 |
cygwin(시그윈) 관련 (0) | 2024.02.18 |