Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
calling system() in cgi

Posted by Yenan (Yenan), 24 July 2003
Hello,

I have a cgi script in C which I am using to make a system call. However I get no response from my linux shell when I run it on my web browser.

The cgi file is test.c:

int main()
{
printf ("%s%c%c\n",
"Content-Type:text/html;charset=iso-8859-1", 13, 10);
system("echo testing");
}

I should see "testing" appear on my linux shell where I run the program.

Please help.

Posted by admin (Graham Ellis), 24 July 2003
Welcome, Yenan. I have moved this topic here from the Perl forum, as the subject is the C language and not the Perl language.

As I understand it, the system() function creates a new process in which to run the command you give it (interpretted via the shell).  Although the stdin and stdout of the CGI process are connected to the web server, this isn't the case with the the subshell - thus you see nothing.

I'm not very comfortable with using C and system calls for a CGI application - I think there might be a much better way of achieving what you want to do.  If you can explain your application further, I'll try to suggest some alternatives

Posted by Yenan (Yenan), 25 July 2003
Hello,

Thanks for your reply. What I am trying to do is modify graphic images via the browser. For example if a user has an image (.bmp, .jpeg etc) he can add text with certain fonts overlayed onto the image. I hoped to be able to used netpbm package to perform graphic manipulations. Do you have any other ideas ? Netpbm converter commands are executed using system calls.

Thanks again.

Posted by admin (Graham Ellis), 25 July 2003
Personally, I manipulate graphics with PHP which has some excellent libraries ...



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho