0

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?

user1166981
  • 1,738
  • 8
  • 26
  • 44

3 Answers3

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.

Community
  • 1
  • 1
The Nail
  • 8,355
  • 2
  • 35
  • 48