To set up CGI program in your web page, please follow these steps:
- Transfer your CGI program (e.g., <cgi-program-name>) into cgi-bin subdirectory under your UNIX account (i.e., /<login-name>/public_html/cgi-bin/ ). For example, you may use WinSCP to transfer your file into your UNIX account. For details of using WinSCP, please refer to Publishing Web Pages in EdUHK.
* Please note that your CGI program must be uploaded as ASCII mode via FTP. - Login your UNIX account (e.g., using SimpTerm) on
- sun.ied.edu.hk (for staff) or
- moon.ied.edu.hk (for students)
- Go into cgi-bin subdirectory by typing in: cd public_html/cgi-bin/
- It is assumed that the file <CGI-program-name> is already stored in cgi-bin sub-directory. After placing the cgi program in the cgi-bin sub-directory, you have to release the access file right to other people to access your program by typing in:
chmod u+x <CGI-program-name>
where <CGI-program-name> is the name of your cgi program. - To run your CGI program, you can use the following address in the URL field of your Web browser or an anchor in your HTML file:
http://home.ied.edu.hk/~<login-name>/cgi-bin/<CGI-program-name>
where <login-name> is the account name of your sun/moon account and the <CGI-program-name> is the name of your cgi program copied to the cgi-bin sub-directory. - The following is a sample cgi program called hello.cgi.
#!/bin/sh
# (or use #!/usr/local/bin/perl for Perl scripts)
echo Content-type: text/plain
echo
echo Hello, worldAfter you create a file called hello.cgi with the above content in the cgi-bin sub-directory, you can then run your file using the URL address as discussed above.