Jean, your script works when run as an osascript, however I'm trying to run 
the script as a BBEdit OnDocumentSave

In that case I've fixed the syntax errors (as best I can, probably 
incorrectly) and it only runs to the first 'do shell script', nothing after 
that executes.

$HOME/asecho is just "echo $* >> $HOME/Desktop/trace" for logging purposes.

     David


-- text document doc

*on* documentDidSave(vDocument)

   *do shell script* "$HOME/asecho run"

   *if* vDocument *is* FTP *then*

       *do shell script* "$HOME/asecho is FTP file"

       *set* vFTPInfo *to* FTPInfo *of* vDocument

       *set* vFile *to* vFTPInfo's *file*

       *set* vHost *to* vFTPInfo's host

       -- set vURL to vFTPInfo's URL -- WARNING: triggers an error even 
though the property exists and is visible in the results pane.

       *set* vURL *to* vDocument's *URL*

       *log* {vHost, vURL}

       *do shell script* "$HOME/asecho is FTP file" & vHost & " " & vURL

   *else*

       *do shell script* "echo is NOT FTP file"

       *if* vDocument's modified *then*

           *save* vDocument

       *end* *if*

       *set* vFile *to* vDocument's *file*

       *set* vPosixPath *to* POSIX path *of* (vFile *as* *string*)

       *do shell script* "$HOME/asecho is NOT FTP file" & *the* quoted form 
*of* vPosixPath

   *end* *if*

   *log* vFile

   *set* vPosixPath *to* POSIX path *of* (vFile *as* *string*)

   *log* vPosixPath

   *do shell script* "$HOME/asecho run ls on " & *the* quoted form *of* 
vPosixPath

   *do shell script* "ls -al" & space & *the* quoted form *of* vPosixPath

*end* documentDidSave

On Sunday, May 8, 2022 at 2:12:53 AM UTC-7 jj wrote:

> Hi David,
>
> `try ... on error`  blocks  are very useful for debugging scripts.
>
> Before porting it to a Document Script, test your logic in the Script 
> Editor where you can use the `log` and `display alert/dialog` commands to 
> debug.
>
> Use `the quoted form of`  for paths included  in your `do shell script` 
> commands, otherwise any space in the path will break your command.
>
>
>>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/17072a9a-c9e8-404f-8fe1-e0ec7b322b30n%40googlegroups.com.

Reply via email to