Script Wysardry
Adapting Perl CGI Scripts

Perl CGI Script Tutorial 9 - Final Stage.



Home / Script / Tutorial 9

Back | Next

Back to the script

Now we need to put that into practice to change the mailing method used by the script from SMTP to sendmail.

Comment out the line that says
$SMTP_SERVER="localhost";
so that it is now
#$SMTP_SERVER="localhost";

Uncomment and edit the line that says
#$SEND_MAIL="/usr/lib/sendmail -t";
so that it becomes
$SEND_MAIL="/usr/sbin/sendmail -t";

Please notice that not only is the line no longer a comment, the lib part was changed to sbin - this is important.  The sendmail routine is at /usr/sbin/sendmail at Spaceports.


Update Start

Sendmail is currently disabled, but it may be enabled again at a future date - make this change now while it is still fresh in your mind.

Update End


Edit the line that says
$lockfile= "/tmp/bnbform.lck";
so that it reads
$lockfile= "/home/user/public_html/bnbform/bnbform.lck";
replacing user with your own username. Do not put the ~ symbol in there as this is a UNIX path, not a URL.

Those who signed up for their CGI-BIN account after the end of July 2000 but before the middle of February 2002 will need to replace home with home2 in that path.

Those who received their CGI-BIN account after the middle of February 2002 will need to replace home with home3 in that path.

The reason for changing the path to this file is so that it is placed in your own server space, not in the shared area.  You are unlikely to have permission to write to that area, and even if you did, others might be using the same script and therefore the same filename.

The idea of the locking file is to stop two people sending forms at the same time and therefore having two instances of the script trying to access the log file simultaneously.  This would likely lead to a loss of data, perhaps all of it.

Save this file!

That is all the editing that is needed for the script to be usable.


Uploading the files

  • Start your FTP program, and connect to your 'planet' account.
  • Create a new directory called bnbform and transfer all the files from your local version into it.  If there is a shortcut you know about that will allow you to do that in one operation, then feel free to use it.
  • Disconnect from that account - we're finished with it for now.
  • Connect to your CGI-BIN account.
  • Create a new directory called bnbform
  • CHMOD it to 755
  • Transfer the two files from your local version into this directory in ASCII mode.
  • CHMOD bnbform.cgi to 755
  • CHMOD mymessage.baut to 777 or 666 - either will work as the file does not need to be executable.
  • Update: Create a new directory inside bnbform called data
  • Update: CHMOD it to 777
  • Disconnect from the server.

You can now test the form out by going to the URL of your form which will look a little like this:-

http://io.spaceports.com/~user/bnbform/bnbform.html

If you get an error message when you hit the send button you made a mistake in the editing somewhere.  If you just see the Spaceports main page, then the error is likely to be related to the uploading.  It is possible you set the script URL wrong though.


Update Start

You will need to check that you can read the form1.bout file that is inside your bnbform/data directory.  If you have write errors when the script is first used, you may need to create an empty text file called form1.txt, upload it inside that directory and then rename it form1.bout and CHMOD the file to 777.

When everything is working correctly, you will need to password protect the data directory, so your next step is to take a look at the Secure Area instruction page.  If you don't, it is possible for others to read the file containing messages intended for your eyes only, as anyone who looks at the HTML for your form page can work out the filename and location.

Update End


When you are ready, the next pages contain references that you may need when adapting other scripts.

Site Menu

Bravenet

Section Menu


Copyright © 2000-2003 Wysardry

Most recently updated on 11 May, 2003

Home / Script / Tutorial 9

Back | Next


Please feel free to contact us with any comments or suggestions
Adapting Perl CGI Scripts
Script Wysardry

This site is hosted by Spaceports