Shell script statement works in Terminal, fails in Hazel

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I have written a shell script that

1) reads the comment tag from an MP3 file with ExifTool
2) converts the MP3 to a different format with ffmpeg
3) writes back the comment to the new mp3 with eyeD3 with the line

Code: Select all
/usr/local/bin/eyed3 --encoding utf8 --v2 --comment "$sMP3TagComment" "$sOriginalDateiname"

This works perfectly when running it in Terminal or in CodeRunner.

However, when using it as an external script in a Hazel rule and applying it to the same MP3 file, the "eyeD3" command line fails with the error
Code: Select all
eyeD3: error: argument -c/--comment: invalid UnicodeArg value: 'eyeD3: error: argument -c/--comment: invalid UnicodeArg value: '1. Unerm\xc3\xbcdlich, engagiert und streitbar - Bischof Erwin Kr\xc3\xa4utler im Gespr\xc3\xa4ch.'

I am puzzled why running the script through Hazel would seem to influence string encoding?
WorkflowsGuy
 
Posts: 30
Joined: Thu Jul 04, 2013 3:55 pm

I'm not sure but keep in mind that when run in Hazel, your environment is different. Maybe eyeD3 requires some env var to be set.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you for pointing this out.

I had assumed that the default character encoding for every shell environment is UTF-8, but obviously not.

After adding

Code: Select all
LC_CTYPE=UTF-8
export LC_CTYPE

as the first statements of my script, it now also works correctly in Hazel.
WorkflowsGuy
 
Posts: 30
Joined: Thu Jul 04, 2013 3:55 pm


Return to Support

cron