Append a running text file

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

Append a running text file 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
guppyguy
 
Posts: 6
Joined: Fri Aug 10, 2012 6:01 pm

Re: Append a running text file 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?
guppyguy
 
Posts: 6
Joined: Fri Aug 10, 2012 6:01 pm

Re: Append a running text file 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.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Append a running text file 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
guppyguy
 
Posts: 6
Joined: Fri Aug 10, 2012 6:01 pm

Re: Append a running text file 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.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Append a running text file 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
guppyguy
 
Posts: 6
Joined: Fri Aug 10, 2012 6:01 pm

Re: Append a running text file 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.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Tips & Tricks - DO NOT POST QUESTIONS