Frequently Asked Questions on Ch Applet
Q: How can I run Ch applets from remote servers on my client machine, instead of just downloading the source code? To run a safe Ch program with file extension .sch downloaded from a Web server as an applet, the following setup procedures for a client of the Ch language environment shall be followed.
Q: How can I send Ch applets from my server so that clients will execute them, instead of just downloading the source code? Ch CGI User's Guide has detailed instructions on how to setup different Web servers for handling Ch applets. Make sure after setup, restart the Web server. Q: Why does a command can run in a terminal prompt, but cannot be executed in a Ch applet? A Ch applet is normally executed in a safe shell for security reason. The command line option -S of the Ch program started by the client of the Ch language environment indicates that the applet will be executed in safe shell. The path for commands executable by the safe shell is contolled by the system-wide startup file CHHOME/config/schrc which includes ~/.schrc in your home directory. Besides the path for Ch programs, the path CHHOME/sbin/ contains system level programs executable from the safe shell. You can symbolically link other commands to this directory. For example, if you want to invoke my_command from a Ch applet, you can type ln -s /my_command_path/my_command my_commandinside the sbin directory. Since applets are downloaded from Web servers and executed in your local machine, make sure you do not put destructive commands such as rm in this directory. Q:How can a dynamic applet be created by CGI and executed across network? If a CGI program dynamically creates a Ch applet in the fly and the applet is then executed in a client machine, then such an applet that is created and delivered on demand is called dynamic applet. To create a Ch dynamic applet, the first line of output from the CGI script should be
content-type: application/x-sch
to
indicate that the output
is
the MIME type of Ch dynamic applet.
For example,
This
CGI script
will create the following dynamic applet,
#include<stdio.h>
int main() {
double x = 3;
printf("x = %f, ", x);
printf("x*sin(2*x) = %f\n", x*sin(2*x));
}
Note: A very difficult-to-debug
mistake in the creation of dynamic
applet is that the newline character is missing.
For example, if the last output statement of
this CGI script
is
printf("}");
instead of
printf("}\n");
The created dynamic applet will not work.
|