Fedora Linux Support Community & Resources Center
Old 24th February 2008, 05:05 AM
jmaynard Offline
Registered User
Join Date: Feb 2008
Posts: 2
Apache/PHP/Perl exec() problem

I am running the following code on my Apache server to return the error since my script without 2<&1 returns no data:

== x.php
$run = "/usr/bin/perl x.pl 2<&1";
exec($run, $output, $input);
$count = count($output);
echo "Element count is " . $count . "<br>";
$test = $output[0];
print $test;

== x.pl
use Net::Telnet:isco::IOS;
$connection = Net::Telnet:isco::IOS->new(Host => "router");
$connection->login("xxxxxxxx", "xxxxxxxx");
@interfaces = $connection->listInts();
foreach $int ( @interfaces )
$desc = $connection->getIntDesc( $int );
$intip = $connection->getIntIP( $int );
printf("%10s: %30s: %20s: %100s: %s","Interface", $int, $intip, $desc, "\n\n");

When I run the php x.php file from a web broswer I get:

problem connecting to "router", port 23: Permission denied at x.pl line 23

When I run it from a command line I get:

Element count is 18<br> Interface: FastEthernet0/0:

On my Windows development machine I do not have this problem and have run into a brick wall trying to figure it out. Can someone please help??
Reply With Quote
Old 24th February 2008, 08:35 AM
notageek Offline
Registered User
Join Date: Jan 2008
Location: N/A
Posts: 2,148
I suspect Apache user doesn't have the relevant privilege to run the following code

$connection = Net::Telnet::Cisco::IOS->new(Host => "router");
$connection->login("xxxxxxxx", "xxxxxxxx");
@interfaces = $connection->listInts();
You may have to either configure sudo or use the Apache suexec module.

Reply With Quote
Old 25th February 2008, 04:36 AM
jmaynard Offline
Registered User
Join Date: Feb 2008
Posts: 2
I do show suexec to be compiled on my machine. In addition, I have set the apache user permission to log in and when I log in as that user I can run the php script and obtain the desired result. While I agree that there apprears to be a permission problem I do not think it is in the script portion. I have additional parts of the script that do not do a socket call that work fine. The permissions appear to be related to the socket call in the Net::Telnet portion of the script.

Can you advise if apache 2.2 has some additional permissions in relation to sockets?
Reply With Quote

apache or php or perl, exec, problem

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache/Perl/Mason config problem Chuck Crisler Servers & Networking 1 14th January 2010 03:03 AM
Apache/Perl/Mason config problem Chuck Crisler Using Fedora 0 13th August 2009 01:46 PM
cgi perl script problem on apache server. penfold2008 Servers & Networking 6 10th July 2009 04:11 PM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Using Fedora 0 17th December 2004 12:42 AM

Current GMT-time: 00:43 (Friday, 22-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat