In php there is shell_exec()
for example, and you can run a program on the local server with it. But what other web-based technologies can do this and how?
Asked
Active
Viewed 119 times
0

user1166981
- 1,738
- 8
- 26
- 44
-
3This is a very broad question. I would assume most server side languages would offer this kind of capability. Is there a particular language you would like to know about? – Jared Feb 27 '13 at 19:56
-
Are you writing an encyclopedia? – The Nail Feb 27 '13 at 19:56
-
1Pretty much all of them. – ceejayoz Feb 27 '13 at 19:56
-
HTML isn't a programming language, and JavaScript (running in a client's browser) can't run programs. – gen_Eric Feb 27 '13 at 19:58
-
Hyper Text Markup LANGUAGE – David Houde Feb 27 '13 at 20:02
-
@DavidHoude: I meant it's not a "programming" language :-) – gen_Eric Feb 27 '13 at 20:02
-
1I know just giving you a hard time ;) – David Houde Feb 27 '13 at 20:12
-
1Yes, it's a MARKUP Language ;-) – The Nail Feb 27 '13 at 20:13
3 Answers
3
ASP:
set wshell = CreateObject("WScript.Shell")
wshell.run "c:\file.bat"
set wshell = nothing
Python:
from subprocess import call
call(["ls", "-l"])
Perl:
system("command arg1 arg2 arg3");
Ruby:
system("ls")
JSP/Servlet:
ProcessBuilder pb =
new ProcessBuilder("/bin/sh", "-c", "myfolder/myscript.sh > /myfolder/logs/myscript.log");
pb.start();
PHP:
shell_exec ( 'command' )

David Houde
- 4,835
- 1
- 20
- 29
2
You can use a cron job, CGI script with any supported language, and of course any web language (including Python, Ruby, Lisp, Java) which your web server can be configured to execute. That said, it's usually inadvisable to execute an application directly; it can lead to high server load and security exploits.

David Houde
- 4,835
- 1
- 20
- 29

omniuni
- 133
- 7
1
For Javascript:
Client side, on Windows it could be done using ActiveX: How to execute shell command in Javascript. But it requires you to allow unsigned ActiveX controls, which introduces a major security issue.
And there is server-side Javascript, called node.js. See the SO question node.js execute system command synchronously on how to use it to execute system commands.