Page 1 of 1

Different Results through Automator

PostPosted: Sun Aug 03, 2014 7:51 am
by ryanaspire
Being a scripting novice, I've hacked together a script that uses a command line utility to read maverick tags and then manipulates the output and send Evernote an email with the tags and the file.

When running the following script through Automator (as a Bash script):

Code: Select all
#Set the name of the destination Evernote notebook
notebook="setnotebooknamehere"

#Set the name of the destination Evernote notebook
enemail="you@email.com"

#Grab the file tags (using 'Tags') and store them in variable 'mavtags'
mavtags=$(/usr/local/bin/tag --no-name * "$1")

#Manipulate $mavtags var to create hashtags
hashtags=$(echo $mavtags | tr ',' '\n' | sed -e 's/^/#/')

#convert multiline $hashtags to single line var $entags
entags=$(echo $hashtags | sed ':a;N;$!ba;s/\n/ /g')

#creating the name of the note
#remove the filepath
filename=$(n)
extension="${filename##*.}"
filename="${filename%.*}"

#Compose and send email using Mutt
/usr/local/bin/mutt -s "$filename @$notebook $entags" $enemail -a "$1" < /dev/null


I get the expected following output:
@setnotebooknamehere #Yellow


However, when I run the same script using Hazel, I get the follow unexpected result:
@setnotebooknamehere #invoice 2014/15 #Blue #tax 2014 #hazproc #invoice receipt #tax Yellow #swipe invoice #paid #paypal #s 2014/13 #Blue #receipt inbox 2014 #hazproc #invoice 2014 #hazproc #invoice 2014 #hazproc #invoice 2014 #hazproc 2014 #haz


Not knowing the particular of the tag utility (https://github.com/jdberry/tag), does anyone know what could be effecting the results in Hazel?

Thanks
Ryan

Re: Different Results through Automator

PostPosted: Mon Aug 04, 2014 3:20 pm
by Mr_Noodle
I'm even less familiar with it but it's important to note that scripts in Hazel do not run in the same context so you may have to set certain environment variables yourself. Also, to debug, you should print out more information to break down where things are going wrong.