I have a couple of perl scripts. I would like to use Applescript to give them some UI features (one applescipt for each different perl script).
they run from the command line, thus:
the results of the script go into the folder you've navigated to in Terminal (so running it from a folder ~/Test/ puts the results in /Test/).
I should be able to run them from an applescript, either by running a shell script or controlling terminal.
WHAT I'D LIKE TO DO is instead of having the perl script reside as a file somewhere on my mac, I'd like for it to be embedded in the applescript itself. (so it's portable, can be easily moved to different machines, distributed, etc).
I'm only at the beginning of my research on this idea but so far I'm finding mixed answers to whether this is possible from age old posts that aren't exactly what I'm asking.
So, IS what I want to do possible to do?
If the kind of perl script matters to the question, this is a simple sample of the kinds of scripts I'm using. If I can get this to work, the others will work.
they run from the command line, thus:
Code:
>:perl script.pl argument1 argument2.....argumentN
I should be able to run them from an applescript, either by running a shell script or controlling terminal.
WHAT I'D LIKE TO DO is instead of having the perl script reside as a file somewhere on my mac, I'd like for it to be embedded in the applescript itself. (so it's portable, can be easily moved to different machines, distributed, etc).
I'm only at the beginning of my research on this idea but so far I'm finding mixed answers to whether this is possible from age old posts that aren't exactly what I'm asking.
So, IS what I want to do possible to do?
If the kind of perl script matters to the question, this is a simple sample of the kinds of scripts I'm using. If I can get this to work, the others will work.
Code:
#!/usr/bin/perl -w
use strict;
use warnings;
use POSIX;
use Data::Dumper;
# Log activity to a file.
sub Logger {
my $file = shift;
my $msg = shift;
my $stop = shift || 0;
open(my $LOG, ">>", $file) || die "Could not create log file.\n" . $!;
#print $LOG sprintf("%s: %s\n", strftime("%H-%M-%S", localtime), $msg); -Time Stamp in log files
print $LOG sprintf("%s\n", $msg);
close($LOG);
# Exit with error
unless ($stop == 0) { exit 1; }
}
# Globals
my $logfile = strftime("%Y%m%d%H%M%S", localtime) . "_md.log";
my $count = 1;
# Loop through the given numbers
OUTER: foreach my $number (@ARGV) {
# Create a directory. Make sure it exists. Log an exit if you cannot.
unless (-d $number) {
mkdir($number);
unless (-d $number) {
Logger($logfile, sprintf("%s. Could not make directory",$count,$number));
}
}
$count++;
}
# Log the end of the program
# Logger($logfile, "Stopping");
# exit without error
exit 0;