PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 13th, 2012, 09:16 PM
BobS0327 BobS0327 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 118 BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 18 h 48 m 29 sec
Reputation Power: 44
Executing a binary on server

I am trying to execute a binary on a server from a webpage.

My web page code is as follows:

Code:
<html>
<body>
<form action="" method="post">
    <button type="submit" name="button">Turn on Front Porch Light</button>
</form>

<?php 
$var1 = "14";
$var2 = "on";
$var3 = "3m";

 if (isset($_POST['button'])) { exec("'./www/var/HAI.pl'. '$var1, $var2, $var3"); print($status);  } 

?>

</body>
</html> 


and the server perl script is as follows:

Code:
#!/usr/bin/perl -w

my $var1 = '';
my $var2 = '';
my $var3 = '';
$var1 = $ARGV[0];
$var2 = $ARGV[1];
$var3 = $ARGV[2];
print "VAR1: ".$var1."\n";
print "VAR2: ".$var2."\n";
print "VAR3: ".$var3."\n";
system("/bin/hai", $var1, $var2, $var3);
 


I am using the Linux Zoneminder CCTV security camera software which provides a web page for viewing the security cameras. What I am trying to do is add buttons to the web page which would allow me to turn exterior floodlights on/off in the vicinity of the cameras.

I can successfully execute the perl script locally at the server and turn the floodlights on/off but I cannot successfully execute it from the web page.

I would greatly appreciate any assistance in getting this mod to work.

Reply With Quote
  #2  
Old November 13th, 2012, 09:25 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,703 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 5 h 39 m 40 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Could be a variety of things.
1. exec() is disabled
2. The path to the script isn't "www/var/HAI.pl."
3. The shell is complaining about the unclosed quote
4. The script isn't executable
5. The script is executing just fine but you can't tell because you're not capturing its output or exit code

Reply With Quote
  #3  
Old November 14th, 2012, 07:24 AM
BobS0327 BobS0327 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 118 BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level)BobS0327 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 18 h 48 m 29 sec
Reputation Power: 44
I found the source of the problem. It was a malformed exec statement. The statement should look as follows:

Code:
if (isset($_POST['ShedFloodLight33'])) 
{ 
$var1 = "33";
$var2 = "on";
$var3 = "3m";
exec("perl /var/www/HAI.pl $var1 $var2 $var3"); 
} 


My incorrect statement:


Code:
 if (isset($_POST['button'])) { exec("'./www/var/HAI.pl'. '$var1, $var2, $var3"); print($status);  } 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Executing a binary on server

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap