[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] MacPerl/CGI/Applescript problem...



I'm trying to use a Rinaldi external to generate an image to the clipboard,
use Clip2Gif to get the image of the clipboard into a gif, and then tell a
web client where to find it.

I'm running the PCGI from Dec25_95 and MacPerl 5.06r1m.

If I run the script as CGI, the file doesn't get created from the
AppleScript call and the client is unable to find the file.  If I run the
script from inside MacPerl, the file does get created.  If I cut and paste
the applescript portion into Script Editor, the script compiles clean and
runs fine.

Any ideas?  See below for the script...

Grapher.cgi called as:  http://ice1/grapher.cgi?x=1,2,3&y=4,5,6&opts=foo
--------
#!/perl   #required sig

require "mac-cgi-lib.pl";  #you know...

&MacPerl'LoadExternals("ICE:MacHTTP:Mod01-HyperGraph lib"); #load rinaldis

&ReadParse(*args); #pull in get args

($x, $y, $opts) = split('&', $args);  #pick out x data, y data, and opts

$x = "x=256,345,122"; #force values so I can run interactively,
$y = "y=435,162,441"; #commented out if run as cgi

$x = (split(/=/, $x))[1]; #pick off value for x
$x =~ s/,/\n/g;  #change , to \n...hypergraph requires it

$y = (split(/=/, $y))[1];  #same as x
$y =~ s/,/\n/g;  #same as x

$results = &HyperGraph($x,$y, $opts);  #call hypergraph external, catch result

if ($results !~ /^Error:/) {  #did Hypergraph Error? If not, do stuff...

&MacPerl'DoAppleScript(<<END_SCRIPT);  #run clip2gif to get pict off clipboard
tell application "clip2gif"
                activate
                save (the clipboard as picture) as GIF in file
"ICE:MacHTTP:foo.gif"
                return
end tell
END_SCRIPT

       print "Location: foo.gif\n\n"; #send client redirect to get file
       }
  else {  #hypergraph bomed...send error for debug
  print "Content-type: text/plain\n\n";
  print "A HyperGraph Error Occured:\n$results";
}

exit 0;
--------

A note about the applescript.  The 'save (the clipboard as picture)...'
part is required because I've got Jon's commands in.  Jon's commands adds a
property called "the clipboard" and AScript intercepts "the clipboard"
before clip2gif can.

Chris

p.s. no public nit-picking of my code, please...this is no where NEAR it's
final form.

--
                                   --------
   +------------------------------| _   /| |------------------------------+
   | Chris Ice, Software Engineer | \`o_O' | Rockwell Automation          |
   | E-mail: CMIce@mfg.mke.ab.com |   ( )  | 1201 S. Second St.           |
   | Voice:  414.382.2136         |    U   | Milwaukee, WI 53204 USA      |
   +------------------------------|  Ack!  |------------------------------+
       My opinions do not reflect  --------  the views of my employer.