Solved

C CGI Program system call problem

Posted on 1997-08-29
4
199 Views
Last Modified: 2013-12-25
I have a problem with my C cgi program on my NCSA HTTPD v1.5.
THe code look like:
fail = system("the_program_need_to_be_executed 1>/dev/null 2>/dev/null");
printf("show the fail value %d<P>",fail);
if (!fail)
        ............;

else
        ............;

The system call will return 0 if it is successful.
If I ran it from command line, it takes less then 1 sec to finish it.
When I ran it from the browser, it does not print the line.  THe browser seems
to wait for a long time.  I check the process status, the fork child processes
still sittng there.  How can I solve the problem and how can I trap it?

Thank you


                                                                     
                                                         
0
Comment
Question by:kuang
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
Philippe earned 100 total points
ID: 1829956

When you run the script from the prompt, it is run with your uid. The server probably runs with uid 'nobody'. Could that be your problem?

If not, you'll have to be more specific: Does the cgi work at all? Say, does it work if your remove the line 'fail=system...'?
Also, try piping stdout and stderr into a file (eg /tmp/debug) and tell us what you see.

 cheers,

   Philippe


0
 

Author Comment

by:kuang
ID: 1829957
I did ran a test(non cgi) as nobody(web uid).  it works.
I did run that cgi program and try to pipe the stdout and stderr to files which have been generateed but nothing in side the files.

If I comment the system call out it ran ok.

is there anything I can try further?

Thank you

0
 
LVL 84

Expert Comment

by:ozo
ID: 1829958
Could path be set differently when you run as nobody and
when the server runs your program?
Did you try specifying the full pathname to the_program_need_to_be_executed?

0
 
LVL 2

Expert Comment

by:Philippe
ID: 1829959

Kuang,

so we have a program which generates no output, works fine when you run it from prompt and blocks without givin an error message when run from the server.

Did you try ozo's comment? To have the same environment as nobody
would have ,try a 'su - nobody' (the '-' says that you also want to change the environment). You should then be in exactly the same situation as the browser.

Is there any chance that the machine on which you test your script and the machine on which the server runs are not the same?

What does your program actually do? Is it a script or a program you wrote. Does it access any remote files or do something it could need permission for? If you have access to the source of that program you could have it print out some debug information.

We might be able to help you more if you tell us more about that program.

  cheers,

   Philippe

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Running a powershell task to call exe while logged off 8 74
.csv files 5 93
Need to learn promise API 2 51
issue with beginner powershell script. 5 61
Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to dynamically set the form action using jQuery.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question