Page 1 of 1

Append a running text file

PostPosted: Thu Aug 23, 2012 9:08 pm
by guppyguy
How would I set up Hazel to append an existing text file with a text file which meets certain basic criteria?

I'm assuming this is a shell script thing?

Thanks-

Gup

Re: Append a running text file

PostPosted: Thu Aug 23, 2012 11:12 pm
by guppyguy
Here's the shell script I'm running:

cat $1 >> ~//Dropbox/Notational Data/Travel Voucher receipts.txt

Any ideas?

Re: Append a running text file

PostPosted: Fri Aug 24, 2012 2:23 pm
by Mr_Noodle
What's the problem you are seeing?

Also, a few tweaks to your script:
- Put quotes around $1 so that it can handle files/paths with spaces in the name.
- Get rid of the double-slashes. One is all you need.
- Put the path after >> within quotes.

It should end up looking like this:
Code: Select all
cat "$1" >> "~/Dropbox/Notational Data/Travel Voucher receipts.txt"


If it isn't working, check the logs for any errors and post those here.

Re: Append a running text file

PostPosted: Sat Aug 25, 2012 9:22 pm
by guppyguy
Hello-

I tried exactly as you suggested and am getting the following:


2012-08-24 23:14:46.647 hazelworker[3243] TRD08186.txt: Rule Append travel voucher text matched.
2012-08-24 23:14:46.753 hazelworker[3243] [Error] Shell script failed: Error processing shell script on file /Users/Ladd/Dropbox/Action/TRD08186.txt.
2012-08-24 23:14:46.753 hazelworker[3243] Shellscript exited with non-successful status code: 1
2012-08-24 23:14:46.758 hazelworker[3243] Done processing folder Action


I truly appreciate your help!

Gup

Re: Append a running text file

PostPosted: Mon Aug 27, 2012 3:13 pm
by Mr_Noodle
Is you script executable? Looks like you have it saved as a regular text file.

Re: Append a running text file

PostPosted: Mon Aug 27, 2012 7:35 pm
by guppyguy
Not sure I understand the question.

The script is embedded in the hazel rule. I got the idea from this site: http://www.macdrifter.com/2012/07/append-to-dropbox-note-with-drafts-app.html

The text file you see before is the matched file that I want to append to another text file.

Gup

Re: Append a running text file

PostPosted: Tue Aug 28, 2012 5:12 pm
by Mr_Noodle
Ah, sorry. Try executing it on the commandline. To close simulate how Hazel calls it, do something like:
Code: Select all
sh --noprofile --norc script

where script is the script you have saved to a file, called, err, "script".

If it fails there then you need to debug it from there. One common problem is not specifying full paths for any programs referenced.