Shell_Exec - Running a program
Posted: Sat May 09, 2009 9:03 pm
I've got a webcam at home what I'd like to control from work. The webcam I own is a Dlink DCS-5300, basically a LAN based webcam that you can control it to move around. Unfornuately I've got 2 things going wrong for me.
a. My home ISP doesn't allow you to host a webserver. (So I can't access the cam from work directly)
b. My work doesn't allow you to browse to any port other than 80 (http).
But I've got a few things going for me:
a. My wife's work (I'm the system administrator for) can host a webserver.
b. I've got a VPN connection from my home to my wife's work.
I've got the webcam setup to FTP images to my wife's webserver every 5 secs. I can view the images via a webpage from my work.
If I were home and I wanted to view the cam, I could browse to it's IP address. If I wanted to move it the camera, there are buttons on the page to move it up, down, right, left or "home" position. If I highlight the buttons, I figured out the URL to simply move the camera without going to it's homepage. The URL to move it down would look like: http://192.168.2.110/cgi-bin/camctrl.cgi?move=down
So, what I figured I could do it create a script, using a compiled program using a langauge called AutoIT, that will create a IE window to move the cam a certain direction and then close the window out. I then created a PHP script that would use SHELL_EXEC to run the autoit script. Keep in mind this is just a test to see if I can make it work.
When I browse to the "down" webpage from work, it doesn't move the camera and in fact keeps IE running on the webserver. That IE process can't be closed, even under admin rights, unless I reboot the server.
Here's what I know.
1. I think the "down" php webpage is setup right, as I created a similiar one that simply pings the webserver. It works and sends the results back to my browser.
2. The compiled program I created works not using it from the php script. I was at my wife's work and ran the AutoITscript from the server directly and found that the cam had moved.
Here's the 2 scripts:
WebcamDown.exe
Down.php
Sample Ping PHP script
Any thoughts?
a. My home ISP doesn't allow you to host a webserver. (So I can't access the cam from work directly)
b. My work doesn't allow you to browse to any port other than 80 (http).
But I've got a few things going for me:
a. My wife's work (I'm the system administrator for) can host a webserver.
b. I've got a VPN connection from my home to my wife's work.
I've got the webcam setup to FTP images to my wife's webserver every 5 secs. I can view the images via a webpage from my work.
If I were home and I wanted to view the cam, I could browse to it's IP address. If I wanted to move it the camera, there are buttons on the page to move it up, down, right, left or "home" position. If I highlight the buttons, I figured out the URL to simply move the camera without going to it's homepage. The URL to move it down would look like: http://192.168.2.110/cgi-bin/camctrl.cgi?move=down
So, what I figured I could do it create a script, using a compiled program using a langauge called AutoIT, that will create a IE window to move the cam a certain direction and then close the window out. I then created a PHP script that would use SHELL_EXEC to run the autoit script. Keep in mind this is just a test to see if I can make it work.
When I browse to the "down" webpage from work, it doesn't move the camera and in fact keeps IE running on the webserver. That IE process can't be closed, even under admin rights, unless I reboot the server.
Here's what I know.
1. I think the "down" php webpage is setup right, as I created a similiar one that simply pings the webserver. It works and sends the results back to my browser.
2. The compiled program I created works not using it from the php script. I was at my wife's work and ran the AutoITscript from the server directly and found that the cam had moved.
Here's the 2 scripts:
WebcamDown.exe
Down.php
Code: Select all
<?php
shell_exec('WebcamDown.exe');
?>Code: Select all
<?php
$output = shell_exec('ping 127.0.0.1');
echo "<pre>$output</pre>";
//echo "$output";
?>