advertisement

Article:
  AppleScript Primer for Mac OS X
Subject:   perl and applescript answer
Date:   2002-02-09 10:52:16
From:   bwperry
You generally shouldn't use system commands that are launched by CGI programs and linked to Web forms, because someone could send a malicious shell command to the CGI program. That said, you can call AppleScripts from perl using the "osascript" shell command. If you type "man osascript" from a Terminal prompt, you can find out most of what you need to know about this command. Here's an example of a perl script that launches a bit of AppleScript:


#!/usr/bin/perl
use strict;


my $finder = "\"Finder\"";
my @arg = ("osascript -e 'tell app $finder to get file 1'");


system(@arg);


This script returns a reference to a file on your desktop, such as "document file osascript.txt". It uses perl's "system" built-in function. The "-e" switch to the osascript command indicates that the argument to osascript will not be a file name; it will be script source. Notice the way that the quotes around Finder (which AppleScript needs) are preserved by creating a perl variable first.


So I guess you could try running AppleScript from a perl CGI, but I haven't tested it yet. And it's potentially hazardous in terms of server security.


1 to 1 of 1
  1. perl and applescript answer
    2002-02-11 09:49:51  bradrice [View]

1 to 1 of 1