Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

VideoBeagle

macrumors 6502a
Original poster
Aug 17, 2010
823
18
App Q&A testing by request.
I have a Perl script that fetches images from online sites. It's run in terminal.

Just today I upgraded from El Capitan to High Sierra.

Trying out the script, I get this error:

Could not create log file.
Operation not permitted at scav2_dl_daz.pl line 22.

Line 22 is in the following sub-routine
Code:
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; }
}

It's the line:
"open(my $LOG, ">>", $file) || die "Could not create log file.\n" . $!;"

I assume there's a permission issue that changed between El Capitan and High Sierra that's caused the problem, but I don't know what yet....ANYone have some ideas?
 
A more informative error message would show the pathname of the file it's failing to create. That would then give you the info necessary to determine where to look for permissions.

In the absence of a pathname, I'm not sure much more than guessing is possible.

Showing pathnames for failing file operations falls under the "Be specific" rule of thumb about handling errors.
 
  • Like
Reactions: VideoBeagle
A more informative error message would show the pathname of the file it's failing to create. That would then give you the info necessary to determine where to look for permissions.

In the absence of a pathname, I'm not sure much more than guessing is possible.

Showing pathnames for failing file operations falls under the "Be specific" rule of thumb about handling errors.

I'm an idiot.

Your comment made me think "It worked before HS, so what's changed...it writes the log in whatever location the script is being called from, and this is just being called from the home folder."

THEN I looked at the terminal window....and I was calling it from the Volumes folder (I had to check in there for something earlier).
A quick "New Window", confirming it was the home folder, a cut and paste of the script launch, and it's all fine.

Thanks for the smack upside the head.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.