{"id":386,"date":"2015-06-29T16:31:57","date_gmt":"2015-06-29T16:31:57","guid":{"rendered":"https:\/\/www.eskimo.com\/support\/?page_id=386"},"modified":"2020-06-23T19:06:07","modified_gmt":"2020-06-23T19:06:07","slug":"cgi-programs","status":"publish","type":"page","link":"https:\/\/www.eskimo.com\/support\/web-space\/cgi-programs\/","title":{"rendered":"CGI Programs"},"content":{"rendered":"<p style=\"text-align: center;\"><span style=\"font-family: arial,helvetica,sans-serif; font-size: 20pt; color: #008000;\">CGI Programs<\/span><\/p>\n<p><strong><span style=\"font-family: arial,helvetica,sans-serif; font-size: 14pt;\">Basics and File Locations<\/span><\/strong><\/p>\n<p><span style=\"font-family: arial,helvetica,sans-serif; font-size: 10pt;\">\u00a0\u00a0<span style=\"font-size: 12pt;\">\u00a0\u00a0 CGI Programs are programs that execute and then create dynamic web <\/span><\/span><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">content. They can create HTML pages, images, audio or video files, pretty <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">much anything that you can put on the web.<\/span><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 CGI Programs can be written in virtually any scripted or compiled <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">language. The web server is currently a Ubuntu based system.\u00a0 Consequently if you use a compiled language for CGI, your program should be compiled on ubuntu.eskimo.com, a Ubuntu based shell server. We provide many languages for your use in CGI program <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">creation. No matter which language you use, CGI programs must have an <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">extension of &#8220;<strong>.cgi<\/strong>&#8221; and must be executable at least by the owner. <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">Also, for Apache to correctly determine the file type, it should be <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">world-readable.<\/span><\/span><\/p>\n<pre>     chmod 544 file.cgi<\/pre>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 CGI programs must be placed in a directory called &#8220;<strong>cgi-bin<\/strong>&#8221; <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">which resides within your &#8220;<strong>public_html<\/strong>&#8221; directory. You can <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">create this directory online using the following commands.<\/span><\/span><\/p>\n<pre>     cd ~\/public_html\r\n     mkdir cgi-bin\r\n     chmod 755 cgi-bin\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 It is also possible to create this directory with a standard ftp client <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">by first logging into ftp.eskimo.com with your username and password, and <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">then issuing the following commands.<\/span><\/span><\/p>\n<pre>     cd public_html\r\n     mkdir cgi-bin\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 In the case of ftp, when you login with your username and password, <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">you will already be in your home directory. When you use mkdir within <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">ftp, it will create the directory with the correct permissions.<\/span><\/span><\/p>\n<p><strong><span style=\"font-family: arial,helvetica,sans-serif; font-size: 14pt;\">How CGI Programs Are Called<\/span><\/strong><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 If your site is a user site under <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">our domain with a URL like <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">&#8220;http:\/\/www.eskimo.com\/~user&#8221;, then your CGI <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">program would be called as <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">&#8220;http:\/\/www.eskimo.com\/~user\/cgi-bin\/program.cgi&#8221;.\u00a0 You can make your CGI web page appear to be somewhere other than cgi-bin on your website by using .htaccess to map the desired URL to the physical location.<br \/>\n<\/span><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 There is also a system cgi-bin directory in which CGI programs that we <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">make available can be accessed. Programs in this directory are called as <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">follows, <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">&#8220;http:\/\/www.eskimo.com\/cgi-bin\/program.cgi&#8221;.\u00a0 This is mostly used for programs that have system constants such as mail-back scripts.<br \/>\n<\/span><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 If you have a virtual domain, your CGI programs would be called as <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">follows, &#8220;http:\/\/www.example.com\/~user\/cgi-bin\/program.cgi&#8221;.<\/span><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">System cgi-bin programs under your virtual domain would be called as <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">follows,<\/span><\/span><br \/>\n<span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\"> &#8220;http:\/\/www.example.com\/cgi-bin\/program.cgi&#8221;.<\/span><\/p>\n<p><strong><span style=\"font-family: arial,helvetica,sans-serif; font-size: 14pt;\">Scripting Languages<\/span><\/strong><\/p>\n<h4><span style=\"font-family: arial,helvetica,sans-serif; font-size: 10pt;\">\u00a0\u00a0\u00a0\u00a0 <strong>Perl<\/strong><\/span><\/h4>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 Perl is far the most prevalent scripted language used for CGI programs. <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">On Eskimo, the path to perl is &#8220;\/usr\/bin\/perl&#8221;. <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">It is version 5.10.1 presently and built with multi-thread support. <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">Unlike perl4, there is no separate taintperl, instead perl is called with <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">-T to provide this capability.<\/span><\/span><\/p>\n<p><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">\u00a0\u00a0\u00a0\u00a0 All perl CGI programs must start with:<\/span><\/p>\n<pre>     #!\/usr\/bin\/perl\r\n<\/pre>\n<p><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">\u00a0\u00a0\u00a0\u00a0 CGI programs requiring taintperl should start with:<\/span><\/p>\n<pre>     #!\/usr\/bin\/perl -T\r\n<\/pre>\n<table style=\"border: 0px none ! important; margin-left: 50px;\">\n<tbody>\n<tr>\n<th style=\"width: 50%;\"><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">Perl Documents<\/span><\/th>\n<th style=\"width: 50%;\"><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">URL<\/span><\/th>\n<\/tr>\n<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">Perl Homepage<\/span><\/td>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\"><a href=\"http:\/\/www.perl.org\/\">http:\/\/www.perl.org\/<\/a><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">Perl Articles (O&#8217;Reilly)<\/span><\/td>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\"><a href=\"http:\/\/www.perl.com\/\">http:\/\/www.perl.com\/<\/a><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">Comprehensive Perl Archive<\/span><\/td>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\"><a href=\"http:\/\/www.cpan.org\/\">http:\/\/www.cpan.org\/<\/a><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">Perl Mongers<\/span><\/td>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\"><a href=\"http:\/\/www.pm.org\/\">http:\/\/www.pm.org\/<\/a><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 There is also an online manual you can access from the shell command <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">prompt by typing, &#8220;man perl&#8221;.<\/span><\/span><\/p>\n<h4><span style=\"font-family: arial,helvetica,sans-serif; font-size: 10pt;\">\u00a0\u00a0\u00a0\u00a0 <span style=\"font-size: 12pt;\"><strong>Python<\/strong><\/span><\/span><\/h4>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 Python is available for web scripting (and other uses). The path to <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">python is &#8220;\/usr\/bin\/python&#8221;. The version of python <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">installed here is version 2.4.4.<\/span><\/span><\/p>\n<p><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">\u00a0\u00a0\u00a0\u00a0 Python CGI scripts should be mode 544 and must start with:<\/span><\/p>\n<pre>     #!\/usr\/bin\/python\r\n<\/pre>\n<p><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">\u00a0\u00a0\u00a0\u00a0 Python documentation can be found at <a href=\"http:\/\/www.python.org\/doc\/\">http:\/\/www.python.org\/doc\/<\/a>.<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 There is also an online manual you can access from the shell command <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">prompt by typing, &#8220;man python&#8221;.<\/span><\/span><\/p>\n<h4><span style=\"font-family: arial,helvetica,sans-serif; font-size: 10pt;\">\u00a0\u00a0\u00a0\u00a0 <span style=\"font-size: 12pt;\"><strong>Ruby<\/strong><\/span><\/span><\/h4>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 Ruby is available for web scripting (and other uses). The path to <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">ruby is &#8220;\/usr\/bin\/ruby&#8221;. The version installed <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">here is ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux].<\/span><\/span><\/p>\n<p><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">\u00a0\u00a0\u00a0\u00a0 Ruby CGI scripts should be mode 544 and must start with:<\/span><\/p>\n<pre>     #!\/usr\/bin\/ruby\r\n<\/pre>\n<p><span style=\"font-family: arial,helvetica,sans-serif; font-size: 10pt;\">\u00a0<span style=\"font-size: 12pt;\">\u00a0\u00a0\u00a0 Ruby documentation can be found at <a href=\"http:\/\/ruby-doc.org\/\">http:\/\/ruby-doc.org\/<\/a> and <a href=\"http:\/\/www.ruby-lang.org\/en\/documentation\/\">http:\/\/www.ruby-lang.org\/en\/documentation\/<\/a>.<\/span><\/span><\/p>\n<p><span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\">\u00a0\u00a0\u00a0\u00a0 An online manual that can be accessed from the shell command prompt by<\/span><br \/>\n<span style=\"font-family: arial,helvetica,sans-serif; font-size: 12pt;\"> typing, &#8220;man ruby&#8221;.<\/span><\/p>\n<p><strong><span style=\"font-size: 14pt;\">Compiled Languages<\/span><\/strong><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif;\">\u00a0\u00a0\u00a0\u00a0 CGI programs can also be written in any of the supported compiled <\/span><span style=\"font-family: arial,helvetica,sans-serif;\">languages. Any compiled programs must be created on ubuntu.eskimo.com<\/span><span style=\"font-family: arial,helvetica,sans-serif;\">.<\/span><\/span><span style=\"font-family: arial,helvetica,sans-serif; font-size: 10pt;\"><span style=\"font-size: 12pt;\"> It is recommended that any compiled CGI program developed off-site be recompiled here before use in order to insure compatibility with the system libraries provided here.<\/span><br \/>\n<\/span><\/p>\n<hr \/>\n<p><strong><span style=\"font-family: arial,helvetica,sans-serif; font-size: 14pt; color: #c00000;\">Warning<\/span><\/strong><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif; color: #c00000;\">\u00a0\u00a0\u00a0\u00a0 CGI programs execute with your permissions. If there is a flaw in your <\/span><span style=\"font-family: arial,helvetica,sans-serif; color: #ff0000;\">program that is exploitable remotely, your files and website may be <\/span><span style=\"font-family: arial,helvetica,sans-serif; color: #ff0000;\">damaged.<\/span><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif; color: #c00000;\">\u00a0\u00a0\u00a0\u00a0 Many shared hosting sites execute all code under a common user ID. In <\/span><span style=\"font-family: arial,helvetica,sans-serif; color: #ff0000;\">that situation, a flaw in any users code can result in damage to all users <\/span><span style=\"font-family: arial,helvetica,sans-serif; color: #ff0000;\">websites. Here, where each users website executes under their own user <\/span><span style=\"font-family: arial,helvetica,sans-serif; color: #ff0000;\">ID, only your own code can expose your own website.<\/span><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><span style=\"font-family: arial,helvetica,sans-serif; color: #c00000;\">\u00a0\u00a0\u00a0\u00a0 Programs should be very careful to eliminate any &#8220;..\/&#8221; back references, <\/span><span style=\"font-family: arial,helvetica,sans-serif; color: #ff0000;\">wild card or regular expression references to file names or commands, or <\/span><span style=\"font-family: arial,helvetica,sans-serif; color: #ff0000;\">references to files or commands starting at &#8220;\/&#8221;. Care should be taken to <\/span><span style=\"font-family: arial,helvetica,sans-serif; color: #ff0000;\">make sure input does not overflow input buffers.<\/span><\/span><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CGI Programs Basics and File Locations \u00a0\u00a0\u00a0\u00a0 CGI Programs are programs that execute and then create dynamic web content. They can create HTML pages, images, audio or video files, pretty much anything that you can put on the web. \u00a0\u00a0\u00a0\u00a0 &hellip; <a href=\"https:\/\/www.eskimo.com\/support\/web-space\/cgi-programs\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":377,"menu_order":0,"comment_status":"open","ping_status":"open","template":"showcase.php","meta":{"footnotes":""},"class_list":["post-386","page","type-page","status-publish","hentry","wpautop"],"_links":{"self":[{"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/pages\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/comments?post=386"}],"version-history":[{"count":2,"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/pages\/386\/revisions"}],"predecessor-version":[{"id":1060,"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/pages\/386\/revisions\/1060"}],"up":[{"embeddable":true,"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/pages\/377"}],"wp:attachment":[{"href":"https:\/\/www.eskimo.com\/support\/wp-json\/wp\/v2\/media?parent=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}