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
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
calling system() in cgi

Posted by Yenan (Yenan), 24 July 2003

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

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 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., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho