I am currently running a perl script for the web and need it to run with sudo.

Here's how the code starts
#!/usr/sbin/sudo /usr/bin/perl

use CGI qw(:standard);

for some reason it seems to not really load the CGI module.

If i take some input (let's say a var called test) it will not print anything

Here's an example
let's say I go to
and my code says
#!/usr/sbin/sudo /usr/bin/perl

use CGI qw(:standard);

print "Content-type: text/html;\n\n";
print "Test = " . param('test');

the param('test') will be empty...

Any ideas?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi  TeleKawaru,

why are you running it with:
#!/usr/sbin/sudo /usr/bin/perl

and not

I think you would be better off looking at suexec, its designed for this wort of thing:
TeleKawaruAuthor Commented:
It needs to run sudo because the perl script needs to run as root and not apache.
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

"The suEXEC feature -- introduced in Apache 1.2 -- provides Apache users the ability to run CGI and SSI programs under user IDs different from the user ID of the calling web-server."

... which is rather the point isn't it?
TeleKawaruAuthor Commented:
no because by default suexec is compiled to use uid 100 and modifying the gentoo ebuild to support uid 0 would result in issues for future updates.
TeleKawaruAuthor Commented:
Though, it still does not explain why the CGI vars are not returning values...
TeleKawaruAuthor Commented:
Okay I found out the problem.

In the sudoers file, there was an option set to strip environment variables... this was causing the issues with the CGI library. I commented it out and it worked just fine. =/
PAQed with points (250) refunded

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.