Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Using AppleScript to Compose a Message

26 views
Skip to first unread message

Joel Black

unread,
Nov 11, 2024, 5:17:40 AM11/11/24
to pat-users
I am *not* a coder - my coding experience comes from ChatGPT and Google... With that out of the way, I have been using ChatGPT to create AppleScripts for my installation of Pat.

Right now, I'm working on a variation of "pat compose" where the recipient's email and the subject are pre-populated. In this particular email, there is no body - none is needed. My problem is I get an error "sh: pat: command not found" number 127"

Here is the code:

set recipientAddress to "reci...@example.com"
set emailSubject to "Subject of the Email"

-- Define the command to compose the email in Pat Winlink
set patCommand to "pat compose -to " & quoted form of recipientAddress & " -subject " & quoted form of emailSubject

-- Run the command in Terminal
do shell script patCommand


I know the error is telling me the "patCommand" cannot be found but if I set the variable of "patCommand" to "pat compose," does that not set "patCommand" to "pat compose" or is it the appended "-to" that's breaking it?

If it's the "-to," is there another way to do what I'm trying?

Any pointers would be appreciated.

Regards,
Joel - W4JBB/NNB4JB

David Green

unread,
Nov 30, 2024, 6:58:12 PM11/30/24
to pat-users
Have you tried changing the "pat compose -to" to include the full path of the pat command?  

You can use "which pat" to get the path to pat.

73,
Dave WB4KSL

J

unread,
Dec 1, 2024, 4:34:57 PM12/1/24
to pat-users
"I know the error is telling me the "patCommand" cannot be found"
The error is -NOT- telling you "patCommand" cannot be found, so you do not 'know' this.
The error -IS- telling you "sh: pat: command not found", which broken down into pieces is "sh" (the process that's complaining, (your shell)): "pat" (the name of the offending piece): "command not found" (the problem being reported).

If you break it down that way, your shell is telling you that it can't find 'pat'.  This is why you need to specify where 'pat' is by providing the full path to that executable.  For example, on my system, it would be '/usr/bin/pat', instead of 'pat', though the location of pat on your system migth be somewhere else.  The command given by WB4KSL "which pat" should provide you with the full path, assuming your shell knows where it is.  Otherwise you can do something like 'find / -name pat' to search every file on your system and maybe figure it out that way.

-J

Reply all
Reply to author
Forward
0 new messages