The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Logging OmniFocus done items to DayOne through Hazel (http://forums.omnigroup.com/showthread.php?t=27370)

Bill Westwood 2013-02-11 01:45 PM

Trying to run the .sh file does throw up some errors as below:

Last login: Mon Feb 11 18:04:34 on ttys000
unknown-44-4c-0c-e4-3e-2c:~ billwestwood$ /Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh
/Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh: line 1: {rtf1ansiansicpg1252cocoartf1187cocoasubrtf340: command not found
/Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh: line 2: {fonttblf0fnilfcharset0: command not found
/Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh: line 2: f1fnilfcharset0: command not found
/Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh: line 2: f2fnilfcharset0: command not found
/Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh: line 3: syntax error near unexpected token `}'
/Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh: line 3: `}'
unknown-44-4c-0c-e4-3e-2c:~ billwestwood$

At least I know how to test it now!

RobTrew 2013-02-11 01:50 PM

My guess is that you may have saved this from TextEdit, which is fine, but TextEdit can save in two different formats:
[LIST=1][*]Plain text[*]Rich Text (RTF)[/LIST]
Looks like you have saved it as an RTF file, which is legible to humans but not to command shells.

The trick is to make a fresh [B]plain text[/B] copy,
[INDENT]TextEdit > Format > Make Plain Text ⌘⇧T[/INDENT]
and then use the [I]chmod +x[/I] command again to make it executable.

Good luck !

Bill Westwood 2013-02-11 02:12 PM

I'm sorry, this is taking up a lot of your time.
I saved the file as plain text via Word.
I'm still getting an error message:

Last login: Mon Feb 11 23:07:14 on ttys000
lj9hb3q1:~ billwestwood$ /Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh
-bash: /Users/billwestwood/Library/Scripts/OmniFocus/OmniFocusLogDone2DayOne.sh:#: bad interpreter: No such file or directory
lj9hb3q1:~ billwestwood$

RobTrew 2013-02-11 02:21 PM

I think we have probably moved beyond OmniFocus issues to the question of how much one wants to learn about Terminal.app and the shell here.

It may be a bit ambitious to use shell scripts like this when the basics are still a bit unfamiliar. Probably best to start with some tutorial material - there's plenty on the web.

My first guess is that you may be saving from Word (possibly not first choice for shell script editing and testing) with the wrong kind of line-endings (Bash expects LF), but I'm afraid I may not have time to get into the forensics of that :-)

Good luck !

whpalmer4 2013-02-11 03:28 PM

Okay, here's a simple, no-fuss approach.

Select the text of the script from the web page. Do Edit->Copy.

Go to the Terminal app. Type

cat > foo
press the Enter key
do Edit->Paste (all of the selected text should appear)
press the Enter key
press the control key and then without releasing it, press the d key.

You should get the shell prompt back at this point.
Now type

chmod +x foo
press the Enter key

Shell prompt again. At this point, feel free to use the Finder to rename the file.

Bill Westwood 2013-02-12 01:02 AM

That seems to have done the trick, thanks.
All I need to do now is filter out the tasks I want to record, but that shouldn't be too difficult.

Bill Westwood 2013-02-12 09:00 AM

I have the script working, the only problem now is that I can't trigger it from Hazel. If I drag the .sh file to Terminal & run it, the whole thing works fine, creating the DayOne & home folder items as expected. I have left the setup in Hazel as first described in Rob's article, I have added a prompt for a certain time, but either way nothing happens from Hazel.
Any ideas?

Guus 2013-02-12 09:24 AM

Bill, if you check all the steps that were mentioned here it should work. I believe you also mentioned the script didn't work when pasted in the internal option of Hazel. That sounds like there might be a problem with your Hazel.

Guus 2013-02-12 09:27 AM

Rob, a question if I may.

The current entries look like this.
## Wei/Scheduler[:](omnifocus:///task/kIIJ0CzGJa1)
- Afspraak Andries aanpassen @done(17:52)

I would like to have a little less info in the entry like:
- Afspraak Andries aanpassen @done(17:52)

I'm willing to give editing the script a try but is possible or does it need al the information to function at all?

Guus

RobTrew 2013-02-13 06:28 AM

[QUOTE=Guus;120342]
I would like to have a little less info in the entry like:
- Afspraak Andries aanpassen @done(17:52)
[/QUOTE]

You can certainly edit the output – simply adjust the [I]print[/I] statements in:
[CODE]{
if (prj!=$5) {prj=$5;
if (prj!="") {print ("\n" prj_prfx prj "[:](omnifocus:///task/" $2 ")") >> "tmp_pretty.txt" }
else {print ("\nInbox[:](omnifocus:///task/" $1 ")") >> "tmp_pretty.txt"}
}
if ($6!=prj) {print ("- " $6 " @done(" $4 ")") >> "tmp_pretty.txt" }
else {{print "- *Project completed* @done(" $4 ")" >> "tmp_pretty.txt" }}
}[/CODE]

[I]$6[/I] contains the task and [I]$4[/I] contains the date.

You could reduce it right down to something like:

[CODE]{
print ("- " $6 " @done(" $4 ")") >> "tmp_pretty.txt"
}[/CODE]

veel geluk !


All times are GMT -8. The time now is 07:47 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.