Re: Calling Perl from AppleScript
Re: Calling Perl from AppleScript
- Subject: Re: Calling Perl from AppleScript
- From: "Jacopille, David" <email@hidden>
- Date: Mon, 06 Mar 2017 20:48:15 +0000
- Thread-topic: Calling Perl from AppleScript
Marc,
You’re not writing to where you would assume you are. If you add this to the end of your Perl script you’ll see why:
use Cwd;
my $dir = getcwd;
print "WORKING DIRECTORY: $dir";
Then modify your AppleScript’s do shell script to capture the returned value via: set PerlWorkingDirectory to do shell script… so you can look at it.
If you run the Perl script directly you’ll probably get something like “WORKING DIRECTORY: /Users/your_user_name/Desktop”
If you run the same script from the AppleScript you’ll probably get “WORKING DIRECTORY: /”
You may not be looking for test.txt in the computer’s root directory, or, more critically, it looks like you may not have write permissions to the root directory.
Providing full paths in the file handle in your Perl script should help. Or explicitly change to the working directory of your choice via chdir in the Perl script prior to creating the file handle.
Dave
On 3/6/17, 3:22 PM, "applescript-users-bounces+djacopille=email@hidden on behalf of debt" <applescript-users-bounces+djacopille=email@hidden on behalf of email@hidden> wrote:
> On Mar 6, 2017, at 11:41 AM, Thomas Fischer <email@hidden> wrote:
>
> or die "cannot open > test.txt: $!“;
Thanks, Thomas. Adding the “die” statement produced this:
Couldn't open test.txt: Permission denied at /Users/work/Desktop/code/AppleScript/test.pl
So… it appears that the Perl script _is_ being run but it can’t open the text file. This is odd since running the Perl script directly works perfectly.
The permissions on the file are set to 666. What more is AppleScript looking for?
Marc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
MFS Email system made the following annotation
---------------------------------------------------------------------------------------------------------------------------------------
This email communication and any attachments may contain proprietary, confidential, or privileged information. If you are not the intended recipient, you are hereby notified that you have received this email in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited. The sender does not waive confidentiality or any privilege by mistransmission. If you have received this email in error, please notify the sender immediately, delete this email, and destroy all copies and any attachments.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden