Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C CGI Program system call problem

Posted on 1997-08-29
4
Medium Priority
?
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
Philippe earned 200 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

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

715 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