CGI Tips and Tricks
CGI Tips and Tricks
When programming in CGI or any type of
programming for that matter, there are strategies that will help you
maximize your time.
Programmers CGI Editing Tips
Checking for Syntax Errors
If you make a change to a CGI script, and the
script fails, determine any syntax error(s) in the script. To determine
CGI/PL syntax errors, log in via SSH/Telnet and CD to the program directory
and then run...
Perl yourscriptname.cgi or .pl
Based upon the error message(s), edit the
script and re-upload.
One or Two Changes Only
Make only one or two changes and then send
and test. Making too many changes at one time and then having a failed
script will result in more lines of code to search through.
Reference Script - Two Scripts
Have a working script in one location and the
script you are editing in a different location. This way if the edited
version fails, you can refer back to the original for reference if
necessary.
Programming Backup Tips
Local Copies - backup_script.cgi
When editing any program, always make a
backup on your local computer in the event the script fails.
Most programmers begin each day by making a
copy so that they have reference points to return to in the event of
problems. For example...
backup_January01_02_scriptname.cgi
backup_January02_02_scriptname.cgi
Remote Copies - backup_script.cgi
If you have script.cgi located on your
server, and you want to send an updated version, rename the script.cgi to
backup_script.cgi.
Then simply upload the new file, chmod it if
necessary, and run it. In the event it fails and you are unable to
determine why, you can always delete it the failed script and then rename
backup_script.cgi to script.cgi.
Resend via FTP
By following the steps above, if the program
fails, there shouldn't be any need to completely restore your entire site.
Just resend via FTP the last working copy of the script.
Folder Backup versus Site Backup
While you can make a backup of your entire
site, you can also backup just certain folders such as the cgi-bin.
This strategy saves you time by not having large backup files to download.
Plus, there is considerable risk of restoring an entire site when you
consider your folder passwords, server files, etc.
For more details,
review the steps to Backup Your Data.
mySQL
Keep in mind that a backup won't include your mySQL database since the
database isn't within your file space. If you need to
backup your mySQL
database, click here for details.
Please note that scripts can enter infinite
loops and cause problems for any server. Please edit scripts with
care!
For additional assistance visit our
CGI Troubleshooting page. |