- 다른 뜻에 대해서는 PHP shell_exec() 문서를 참조하십시오.
1 Java[ | ]

Java
Copy
// String[] commands = { "bash", "-c", "echo hello" };
String[] commands = { "CMD", "/C", "echo hello" };
Process proc = Runtime.getRuntime().exec(commands);
BufferedReader brOut = new BufferedReader(new InputStreamReader(proc.getInputStream()));
BufferedReader brErr = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
String line;
List<String> outLines = new ArrayList<String>();
List<String> errLines = new ArrayList<String>();
while ((line = brOut.readLine()) != null) outLines.add(line);
while ((line = brErr.readLine()) != null) errLines.add(line);
String newline = System.getProperty("line.separator");
System.out.println("stdOut: " + String.join(newline, outLines));
System.out.println("stdErr: " + String.join(newline, errLines));
// stdOut: hello
// stdErr:
2 PHP[ | ]

PHP
Copy
echo shell_exec('whoami');
# root
PHP
Copy
echo shell_exec('cat /etc/at.deny | head -3');
# alias
# backup
# bin
3 Python[ | ]
Python
Copy
import os
result = os.system('cat /etc/at.deny | head -3')
print result
# alias
# backup
# bin
# 0
Python
Copy
import os
result = os.popen('cat /etc/at.deny | head -3').read()
print result
# alias
# backup
# bin
#
4 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.
- 분류 댓글:
- Python (25)
- Java (3)
리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― Jmnote리눅스 Python 2.7 컴파일 설치 ― ㅇㅇㅇ미운코딩새끼 ― 승호 도령미운코딩새끼 ― 불탄고등어미운코딩새끼 ― 김레이미운코딩새끼 ― 호박이미운코딩새끼 ― Junhg0211미운코딩새끼 ― 김왼손미운코딩새끼 ― 용딘이미운코딩새끼 ―Pinkcrimson
유기농냠냠파이썬 ― 호박유기농냠냠파이썬 ― 이에스유기농냠냠파이썬 ― 이승현파이썬 global ― Jmnote파이썬 global ― John Jeong파이썬 global ― Jmnote파이썬 global ― John Jeong파이썬 global ― John Jeong파이썬 global ― John Jeong파이썬 global ― Jmnote파이썬 global ― John Jeong