digitalzero
06-10-2003, 08:58 AM
I was just wondering whether you could run UNIX commands like:
"clear" or "ls" in Python programs or Java programs.
Anyone know how?
"clear" or "ls" in Python programs or Java programs.
Anyone know how?
|
Click to See Complete Forum and Search --> : Can you run UNIX commands in a Python or Java Program? digitalzero 06-10-2003, 08:58 AM I was just wondering whether you could run UNIX commands like: "clear" or "ls" in Python programs or Java programs. Anyone know how? viperlin 06-10-2003, 09:21 AM i run them in PHP (executed serverside and the results posted on the webpage.) prolly not what your after though. e.g to give a size of my entire website i put this in my page: <?php echo $size =shell_exec("du -sh ../htdocs") ?> see http://zion.alturl.com in the stats section for tricks i've done with PHP like this. stoe 06-10-2003, 09:31 AM yes, you can in both: For Java, see the Runtime.exec method, for example you might do something like: Runtime rt = Runtime.getRuntime(); Process lsProcess = rt.exec("ls -l"); ... and so on http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Runtime.html For Python, something like: import os retCode = os.system("ls -l") ... and so on http://www.python.org/doc/current/lib/os-process.html digitalzero 06-10-2003, 11:33 AM THANKS! Kai99 06-10-2003, 12:19 PM In Python you simply: >>>import os >>>os.system('vi') Will launch the vi editor. Hope it helps, Kai justlinux.com
Copyright Internet.com Inc. All Rights Reserved. |