Running a message board under Personal Web Sharing

I’ve been looking through some of the boards here for a little while now, but can’t find anywhere to start. Let me explain what i want to do…

I’ve got a basic web server setup running Personal Web Sharing version 1.5. With this particular version of PWS I can run CGI scripts on the server. I have installed the ParseCGI OSAX and have been successful at setting up an email.cgi applescript to pass data from a form on the website to an email message.

What I would like to do next is to have an HTML page on the server that acts like a message board. It doesn’t need to be complex at all. I realize that most message boards rely on a database working in the background, and this probably wouldn’t work on this particular setup. So, something simple I’m thinking. If I could have a page on my site that accepts text in a field, then takes that text and writes it into a text file, then saves that text file as HTML, that would work perfectly. I just don’t know where to start…

I know that this will require a CGI of some kind, and probably an OSAX. I just don’t know where to begin. Thanks to anybody that can help!


Hi Jeff,

These are just some pointers, which you may find interesting if you use PWS a lot. One of the things about PWS is that it lacks some of the broader features that most servers offer [ie: support for file includes, etc] - and the fact it’s not scriptable.

But, here ya go! :wink:

Conferweb. A pure applescript acgi. It was written for Webstar, but can be used on PWS too.

acgi Dispatcher

And to be complete, check out Albert

Please be sure to visit our links page. There are many more I suspect I missed that you may find useful.

Hope this helps you and Good Luck

Excellent Ray, that looks like a start in the right direction!

I’ll give it a try and post back with my results. Thanks again!


You don’t need any of those. If you can get a basic AppleScript CGI working, then this is all you need to do: create a new CGI that accepts the data from a form (the comment and the user name, for instance), read a static HTML page, search and replace a marker with the new input, and save the static page. For instance, have a form that looks something like this:

<title>Add Your Comment!</title>
<form action="/cgi-bin/comment.cgi" method=post>
Name: <input type="text" name="the_name" value="" size="35" maxlength="60"><br>
<textarea name="the_comment" rows="10" cols="40">Enter your comment here...</textarea><br>
<input type=submit name=Submit value="Add Your Comment">

Then have a static “comments.html” page like this:

<!-- marker -->

Then, your CGI would look something like this (I don’t remember exactly how the “handle CGI” handler was formatted or how the arguments were extracted, I haven’t done this in a few years, but if you’ve got the email CGI working, then this should be a snap):

property comments_file : "path:to:comments.html"
property crlf : (ASCII character 13) & (ASCII character 10)
property http_header : "HTTP/1.0 200 OK" & crlf & "Server: MacHTTP" & crlf & "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf

on handle CGI request path_args
	--parse your CGI stuff here to extract the_comment & the_name
	set the_string to (read file comments_file)
	set search_string to "<!-- marker -->"
	set replace_string to "<hr>" & return & "<p>" & the_comment & "<br>" & return & "<i>posted by " & the_name & " on " & ((current date) as string) & "</i></p>" & return & "<!-- marker -->"
	set the_string to (my snr(the_string, search_string, replace_string))
	my write_to_file(comments_file, the_string, false)
	return http_header & "Comment added, go to <a href=\"../comments.html\">comments page</a>."
end handle CGI request

on snr(the_string, search_string, replace_string)
	set old_delim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to search_string
	set the_string to text items of the_string
	set AppleScript's text item delimiters to replace_string
	set the_string to the_string as string
	set AppleScript's text item delimiters to old_delim
	return the_string
end snr

on write_to_file(the_file, the_string, with_appending)
	set the_file to the_file as file specification
		open for access the_file with write permission
		if with_appending = false then set eof of the_file to 0
		write (the_string as text) to the_file starting at eof
		close access the_file
	on error
			close access the_file
		end try
	end try
end write_to_file

Be sure to update all the paths.

Again, it’s been a while since I’ve done this (and I can’t test it) but I don’t see why this wouldn’t work.