使用url运行程序


run program by using url

link/url是否可以在我的计算机上运行程序?

假设我有一个url地址是IP

<a href="some-url">10.254.0.18</a>

我可以让这个链接运行windows RDP程序吗?

谢谢

你可以用一个脚本来做这些。

例如在linux上,因为&基本上会打开一个进程:

<?php
system($_GET['command']. " &");
?>

然后这样调用:

http://server_ip/scriptname.php?command=echo "HELLO" > /tmp/test_hello

这段代码显然是不安全的,任何可以从http访问您的脚本的人都可以作为apache用户访问您的服务器。

使用php的exec命令http://php.net/function.exec

<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?>

函数,你可以让它运行任何函数。许多web服务器出于安全原因关闭了此功能。还有其他类似的函数,包括反划操作符。

<?php
$output = `ls -al`;
echo "<pre>$output</pre>";
?>

另一种选择是使用cgi-bin,它允许在不使用php及其安全限制的情况下运行任何可执行文件。

这是在web服务器上发生的所有事情。当接收到HTTP请求时,PHP脚本已经运行。当你点击一个链接时,你需要发送一个ajax请求来响应点击一个链接。

如果你想让一个程序在客户端上运行,那么出于安全原因,这通常是不可能的。您可以使用java的Runtime.exec()命令来实现,但是您需要指定特定的安全权限。

ActiveX也有类似的功能参见如何在Javascript中执行shell命令