Your best friend for file transfer.

Fetch application logoFetch

Invoking Mirror command through BBEdit Unix worksheet (9 posts)

  • Started 11 years ago by Greg Raven
  • Latest reply 11 years ago from Greg Raven
  • Greg Raven Member

    The new versions of BBEdit feature "projects," one option of which is to upload (AKA "Deploy") the project files to your remove server when you're done editing. Unfortunately, doing this takes forever, and while BBEdit is "Deploying," you are locked out of doing anything else.

    I have set up a Mirror for one of my sites, and I was wondering if it's possible to invoke the Mirror command from the project Unix worksheet?

    If not, is there another way I can shell out the upload to Fetch so I can get back to using BBEdit right away?

    Thanks.

    Posted 11 years ago #

  • Jim Matthews Administrator

    Hi,

    Yes, you could invoke the Mirror command from the UNIX worksheet.

    The first step is to create an AppleScript to do the mirror. The easiest way to do that is to open AppleScript Editor, click the Record button, and perform the mirror operation manually. AppleScript Editor should record something like:

    tell application "Fetch"
    activate
    mirror alias "Macintosh HD:Users:joeuser:myfolder:" to url "sftp://username:@example.com/path/to/folder/" format Automatic without delete strays
    end tell

    You can shorten that to a single line:

    tell application "Fetch" to mirror alias "Macintosh HD:Users:joeuser:myfolder:" to url "sftp://username:@example.com/path/to/folder/"

    You can run that script from your BBEdit UNIX worksheet using the osascript command. Note that you should put the script inside single quotes:

    osascript -e 'tell application "Fetch" to mirror alias "Macintosh HD:Users:joeuser:myfolder:" to url "sftp://username:@example.com/path/to/folder/"'

    Let me know if that doesn't work for you.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 11 years ago #

  • Greg Raven Member

    Jim,

    Except for the fact that the AppleScript times out, it seems to work fine from within AppleScript itself. However, when I try running it from the Unix Worksheet in the shortened notation with the osascript -e prefix, it just sits there and stares at me.

    Posted 11 years ago #

  • Jim Matthews Administrator

    To deal with the timeout issue you want to wrap your AppleScript command in a "with timeout" block, such as:

    with timeout of 3600 seconds
    tell application "Fetch" to mirror alias "Macintosh HD:Users:joeuser:myfolder:" to url "sftp://username:@example.com/path/to/folder/"
    end timeout

    If you have an AppleScript that works, I would recommend saving it, and invoking it in BBEdit with a command like this:

    osascript /path/to/applescript

    rather than using -e, which is awkward with multi-line scripts.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 11 years ago #

  • Greg Raven Member

    Jim,

    Got the time-out fixed, and exported the .SCPT to an .APP. Now I'm getting an error telling me the .APP file doesn't exist. The path looks correct, but the OS is rejecting it for some reason.

    Another oddity is that when invoked from the project worksheet, there is no error message ... it just doesn't run.

    Posted 11 years ago #

  • Greg Raven Member

    This is the command in the worksheet:

    osascript iMac_HD:Users:greg:Sites:Atspace:mirror-atspace-gr.app

    Posted 11 years ago #

  • Greg Raven Member

    Here we go:

    osascript ~/Sites/Atspace/mirror-atspace-gr.app

    Posted 11 years ago #

  • Jim Matthews Administrator

    Does that last one work? I wouldn't save it as a .app; the osascript man page does not mention support for .app bundles. Instead, I'd pass osascript either the script text or a compiled script.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 11 years ago #

  • Greg Raven Member

    It seems to be working, but I'll have to make some changes to the project code to verify it. If not, I'll resave. At least I have the path and syntax working now.

    Thanks for your help.

    Posted 11 years ago #

Reply

  • Or nickname, if you prefer.
  • This will be kept confidential.
  • This is to ensure that you’re a person, not a spambot.