Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7069233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:25:15+00:00 2026-05-28T05:25:15+00:00

Here is my program import subprocess print Content-type:text/html\r\n\r\n print File starting to execute print

  • 0

Here is my program
import subprocess

print "Content-type:text/html\r\n\r\n"
print "File starting to execute"
print "<br>"
proc = subprocess.Popen(["sudo", "python", "test3.py"], stdout=subprocess.PIPE)
output = proc.stdout.read()
print "output is %s" %output

print "<br>"
print "File Executed Awesomely"

So when I run it from the command line it works great, like follows->

[root@localhost html]# python test2.py
Content-type:text/html


File starting to execute
<br>

output is .
Sent 1 packets.

<br>
File Executed Awesomely
[root@localhost html]# 

that is perfect the “. Sent 1 packets.” is what I want. But when I run it from the webpage, the webpage just has

File starting to execute
output is
File Executed Awesomely

so I originally thought this was because I was doing something wrong grabbing the output but I listened on the port with wireshark (my other program it calls send a packet) and it looks like no packets shows up via the webpage call, but it does when I call it on the command line (the same way). Looking at my apache error_log->

[Wed Jan 18 18:15:11 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Jan 18 18:15:11 2012] [notice] Digest: generating secret for digest authentication ...
[Wed Jan 18 18:15:11 2012] [notice] Digest: done
[Wed Jan 18 18:15:11 2012] [warn] ./mod_dnssd.c: No services found to register
[Wed Jan 18 18:15:11 2012] [notice] Apache/2.2.17 (Unix) DAV/2 configured -- resuming normal operations

any suggestions on how I can fix it so my apache cgi-bin script runs the same way as the command line?

EDIT: looking at the log after a few calls it does this repeatedly

[Wed Jan 18 18:22:37 2012] [error] [client 10.117.153.89] :
[Wed Jan 18 18:22:37 2012] [error] [client 10.117.153.89] sorry, you must have a tty to run sudo 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:25:16+00:00Added an answer on May 28, 2026 at 5:25 am

    The message sorry, you must have a tty to run sudo is the key. First of all, letting your apache run sudo is dangerous to say the least, but if you really really want to do it… there’s a way, edit /etc/sudoers (visudo) and locate the Defaults requiretty part (man sudoers).

    NB: Never let apache run anything using sudo, specify exactly what it needs to do and nothing more!

    BTW: It may still not work if you have SELinux enabled or other LSM module.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my main file: import subprocess, time pipe = subprocess.PIPE popen = subprocess.Popen('pythonw -uB
Here is my Python program: import re print re.findall( ([se]{2,30})ting, testingtested ) Its output
I've got a Schroedinger's Cat type of problem here -- my program (actually the
So here is my program, which works ok: import java.io.FileReader; import java.io.BufferedReader; import java.io.IOException;
Here's the code I'm running: import re FIND_TERM = r'C:\\Program Files\\Microsoft SQL Server\\90\\DTS\\Binn\\DTExec\.exe' rfind_term
OK so I redefined my last program... here it is: import java.io.BufferedReader; import java.io.InputStreamReader;
I have a program that reads a huge text file (line by line) and
Why is my program giving me an error here? import random TheNumber = random.randrange(1,200,1)
I have a program here: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ipc.h> #include
there is this check-in-out program here at my workplace, it only takes the data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.