Re: writing cgi programs in c: the system() call.



I've written a cgi program in C using the borland 5.5 free compiler,
and it runs just fine on an Apache server.

CGI runs on a *server*. A server need not even have a monitor.
Even if it does, it may be used only when the system is rebooted,
and shared with a dozen other systems via a big KVM switch.

My only issue is if I issue some system calls the cgi suspends until
the call finishes.  for example if in my c program I have a line:

system("notepad");

What does
system("notepad &");
do? It might avoid the suspension until the call finishes (it would
on UNIX), or it might just result in notepad complaining about its
command-line arguments.

I can see with the taskmanager that an instance of notepad.exe is
running, but its not on my desktop and the cgi program that made the
system call suspends until I kill the notepad.exe process.

system() is not going to make anything run on a remote machine unless
the command is very specific about what machine it's supposed to run
on, and all sorts of permissions are set properly. Otherwise:
system("virus");
would be nearly unstoppable.

I even tried imbedding the the notepad call in a .bat file as so:

system("mybatfile.bat");

mybatfile.bat:
REM call a routine
notepad t.txt

I get the same result.

If I re-write mybatfile.bat to some routine that completes
automatically, all goes well for example:

mybatfile.bat:
REM a simple canned routine
dir >t.txt

this works fine and sure enough, there is a new file named t.txt
created.

What is the right way to call notepad from a cgi,

I don't believe there is one.

I imagine one of the
variations of spawn() or exec() will do the trick; I'm hoping some
here will know.

Notepad needs to have a display to function. I don't know how you
give it one. Apache isn't prepared to open windows for CGIs to run
in. On UNIX, you'd need to redirect standard input and standard
output to a terminal or pseudo-terminal. Then there's the problem
that two programs (e.g. notepad and a shell) reading from the
keyboard at the same time gives you problems with the output going
to the correct place.

.



Relevant Pages

  • Re: writing cgi programs in c: the system() call.
    ... and it runs just fine on an Apache server. ... My only issue is if I issue some system calls the cgi suspends until ... I even tried imbedding the the notepad call in a .bat file as so: ...
    (comp.lang.c)
  • Re: writing cgi programs in c: the system() call.
    ... and it runs just fine on an Apache server. ... My only issue is if I issue some system calls the cgi suspends until ... I even tried imbedding the the notepad call in a .bat file as so: ...
    (comp.lang.c)
  • POE-Component-PSD
    ... An HTTP/HTTPS "Persistent Session Daemon" and CGI accelerator. ... lightweight event-driven HTTP/HTTPS server manages sessions ... or proxy through an Apache server ...
    (comp.lang.perl.modules)
  • CGI not novel, instant CAI gratification is garbage (was: JDEE/CGI/flashcards ...)
    ... CGI is just an interface to run ... network to the server, the application processes the ... Google Groups had a simple tree view that for really large threads ...
    (comp.lang.lisp)
  • How Hackers Attack Web Servers, CGIs, PHP, ASP, etc.
    ... Web Site Hacking - General & Miscellaneous ... NetWare Enterprise Web Server - two issues ... SITEWare cleartext passwords, read arbitrary files ... Web Site Hacking - CGI, Perl, ASP, PHP etc. ...
    (soc.culture.indonesia)

Loading