Solved

C CGI Program system call problem

Posted on 1997-08-29
4
197 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now