Applescript and CGI help please ...

buc99

Don't Tread on Me!
I am trying to learn applescript.

The more I delve into it the more I start to believe it is almost a dead language.

Very little information on it.

I've yet to find a proper explanation on how to read a "Dictionary".

And now, it seems that Apache does not want to work with applescript cgi's OSX. Does anyone know if it is possible to use Applescript as cgi in OSX 10.2? Do I need to tweak some setting in Apache?

When I run a test.cgi script written in Applescript I get the following in the browser:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

I get the following from the server log:

[Sun Oct 6 14:37:07 2002] [error] (8)Exec format error: exec of /Library/WebServer/CGI-Executables/test.cgi failed
[Sun Oct 6 14:37:07 2002] [error] [client xx.xx.xx.xx] Premature end of script headers: /Library/WebServer/CGI-Executables/test.cgi


Any ideas how to get this to work?

Thanks.
SA
:)
 
For you apache problem, I don't really have any idea cause i never used it. When it says to contact your system administrator it is basically saying to contact yourself since you are the one that is running the server. I didn't think that an applescript would run as a "cgi-executable" what does your test.cgi look like? And what does your apache file look like? its prolly pretty long so don't paste it, but look on the net for some proper config files.

As for the dictionary question: what are you asking? How to read one or how to open one? If you are asking how to open it, then that is easy. Open the Script Editor and go to open dictionary, then wait a while, for some reason it takes a little while to load. Then a list of all the available dictionaries will come up. choose the one that you want to look at. If you are asking how to read it, then well you just really have to look at them and know what you are looking at. It is basically an object reference. Telling what objects and properties and events you have available to you. Will small examples. I think the best way to learn it though is open up the scripts that apple provides for you. look at them and see what they do. Also, look at Apple's site. they do have some tutorials on applescripting, especially in the ADC. Good luck.
 
That is what I am saying. How powerful is AppleScript now with all of the other scripting languages available?

My test.cgi script is an applescript I saved with the .cgi extension per Apple's website info. Apache still does not want to execute it. Do I have to do something to Apache outside of making the .cgi executable for applescript?

I know how to find a dictionary. Reading it is a chore in it self. You have to hunt down the objects and then figure out what key words to use to make them interact with each other. And the only documentation for this that I have seen, is keep hacking away until you get it. Which is not a very good method for figuring out what info is in the dictionary. So what if I know what type wach object is, I also need to figure out what words to use to make them interact with each other and this is only covered in the basics and not a lot of theory involved.

Basically what I'm looking for is some concrete language rules. I guess you could say there are concrete rules for applescript, but if you compare it to C, Java, Perl, or Python, it does not seem all that concrete. Every language has their variable types and there iteration loops, but AppleScript does some funky things with objects I think.

Not that I'm dogging AppleScript. I'm just not that familiar with it and am looking for good info to help me familiarize myself with the language. But the info I've come across is limited in scope.

Thanks.
SA
:)
 
I agree with you - Applescript sucks. The documentation or lack there of is horrible. I'd like to use but it damn near impossible. I'm trying to get Folder Actions to work for a week now with no luck. When something is dropped in a particular folder I want it copied to 3 other folders and then deleted in the original folder. Seems simple enough but I can't figure out how the hell to do it.
 
I could be wrong on this but here goes some sudo/Applescript for you;
tell application "Finder"
copy item to folder "whatever the destination"
copy item to folder "Next folder destination"
copy item to folder "next folder destination"
end tell

Where item is the name or variable containing the name of the object to be moved and all folder destinations are absolute with ":" instead of the "/" in the path.

Does this help you in the right direction?

I think there is a "delete item" command for Finder also.

Good Luck.
SA
:)
 
Here is a simple backup script. I gives some good examples of the correct way to write a script.

-- DO NOT MODIFY THESE ITEMS!

global localUser
global backupVolume


-- ********************* BEGIN MODIFICATION AREA! ***************
-- Modify the the items in quotes on lines below to match your specific setup.
-- AT the end of each line you will see an complete explanation of what that variable does.


set localUser to "johndoe" -- MODIFY: Enter your local user folder's name here.
set backupVolume to "Backup" -- MODIFY: Specify the name of your backup volume/disk here.

-- Test the script to make sure it works, and once it does, save it as an application to whatever location you want -- then setup CronniX to run it for you automatically.

-- ********************* END MODIFICATION AREA! *********************


tell application "Finder"
if folder localUser of disk backupVolume exists then
delete folder localUser of disk backupVolume
empty trash
copy home to disk backupVolume
else
copy home to disk backupVolume

end if
end tell
 
A little research on apple's applescript page reveals that apache does not recognise applescripts as cgi's. That was limited to OS 9 servers. However there is a shareware application that will make it work. Here is the URL http://www.sentman.com/acgi/
 
Back
Top