Announcement

Collapse
No announcement yet.

Command lines with Mac Applescript?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Command lines with Mac Applescript?

    Hello,

    I'm trying to write an Applescript to compare (sync visible mirror:left->right) a local folder with a distant FTP folder.

    I know I could write a text file (let's say BCompare_Sync_LR.txt, and then put in my Applescript:
    Code:
    do shell script "/usr/local/bin/bcompare @\"/Volumes/SSD/BCompare_Sync_LR.txt\""
    Actually, the text file works fine and contains something like:
    Code:
    criteria timestamp binary
    load "/Users/.../_path_to_my_local_folder" "sftp://_path_to_my_sftp_folder"
    sync visible mirror:left->right
    I would like to know how I could write directly these commands of in the Applescript, without calling a text file. Maybe they should start with:
    Code:
    do shell script "/usr/local/bin/bcompare/..."
    Thanks for you help.

  • #2
    Hello,

    I'm not familiar enough with AppleScript to generate that type of input on the fly. My hunch is it would still need to generate a temporary text file to pass to bcompare, as BC4 needs the command line "bcompare @script.txt" detected in order to execute in scripting mode.

    BC4's command line does support passing arguments into scripting, so the text file can be more static, while passing in the parameters (usually paths):
    bcompare @script.txt "/Users/.../_path_to_my_local_folder" "sftp://_path_to_my_sftp_folder"

    where script.txt then uses:
    criteria timestamp binary
    load "%1" "%2"
    expand all
    folder-report layout:side-by-side output-to:"report.html" output-options:html-color

    Please note that a sync mirror can delete files, so please test any scripting solution on test locations first. BC4 does not support an UNDO command for any actions taken by script, and script offers no preview before automation.

    Would using a combination of Apple script calling to a static script.txt but then also using parameters help with your setup?
    Aaron P Scooter Software

    Comment


    • #3
      Thank you for your reply.

      I was planning to write an Applescript because I have several backups to perform. I now understand I can pass folders path as parameters to the bcompare command, but the problem is my backups don't have the same criterias.
      So, can I pass criteria as parameter in the bcompare @ command?

      Or may be I could pass a variable instead of a text file name (something like bcompare @myVar) ? myVar would be a string built with Applescript and would contain:
      Code:
      criteria timestamp binary
      load "/Users/.../_path_to_my_local_folder" "sftp://_path_to_my_sftp_folder"
      sync visible mirror:left->right
      Thank you.

      Comment


      • #4
        I made some tests so I can reply to myself: critera can be passed as 3rd parameter

        Comment


        • #5
          I still have a bug

          Applescript sends this command with 3 params:
          Code:
          /usr/local/bin/bcompare @'/Users/thierry/PERSO/Développement/AppleScripts Perso/BCompare Svgde/BCompare_Command.txt' '/Users/thierry/PERSO/Développement/AppleScripts Perso' 'sftp.[[[...]]]' binary '
          param #1: '/Users/thierry/PERSO/Développement/AppleScripts Perso' --> local source folder
          param #2: 'sftp.[[[...]]]' --> ftp destination folder (masked for security reasons)
          param #3: binary --> comparison criteria

          All seems OK but Beyond Compare throws error about missiing base folder.
          Here is the log:
          Code:
          09/10/2018 14:15:22  >> # -------------------- Turn verbose logging on.
          09/10/2018 14:15:22  >> log verbose append:"/Users/thierry/Desktop/BCompare Mirror Backups log.txt"
          09/10/2018 14:15:22  >> 
          09/10/2018 14:15:22  >> # -------------------- Set the comparison criteria.
          09/10/2018 14:15:22  >> criteria timestamp binary
          09/10/2018 14:15:22  >> 
          09/10/2018 14:15:22  >> # -------------------- Load source and target folders.
          09/10/2018 14:15:22  >> load "/Users/thierry/PERSO/Développement/AppleScripts Perso"
          09/10/2018 14:15:22  Charger la comparaison : /Users/thierry/PERSO/Développement/AppleScripts Perso <-> 
          09/10/2018 14:15:22  >> load "sftp:// [[[path to my FTP folder]]] "
          09/10/2018 14:15:22  Connecté à ssh. [[[...]]]
          09/10/2018 14:15:22  Clé du serveur [[[...]]]
          09/10/2018 14:15:26  Authentification de Mot de passe réussie.
          09/10/2018 14:15:26  Logiciel du serveur : OpenSSH_6.7p1
          09/10/2018 14:15:26  Compression : none
          09/10/2018 14:15:26  Cryptage : aes256-ctr
          09/10/2018 14:15:26  Algorithme MAC : hmac-sha2-512
          09/10/2018 14:15:26  Connecté à ssh.[[[...]]]
          09/10/2018 14:15:26  Utilisation de la version SFTP 3.
          09/10/2018 14:15:26  Informations du serveur :
          09/10/2018 14:15:26  Dossier actuel : /home/[[[...]]]
          09/10/2018 14:15:26  Charger la comparaison : sftp://[[[path to my FTP folder]]] <-> 
          09/10/2018 14:15:26  >> 
          09/10/2018 14:15:26  >> filter "-.DS_Store"
          09/10/2018 14:15:26  >> 
          09/10/2018 14:15:26  >> # --------- Sync the local files, creating empty folders.
          09/10/2018 14:15:26  >> sync create-empty mirror:left->right
          09/10/2018 14:15:35  >> L'utilisateur a annulé
          09/10/2018 14:15:35  Script terminé en 12,8 secondes
          If a perform an equivalent script from terminal, log is different. Here it is:
          Code:
          09/10/2018 14:29:39  >> # -------------------- Turn verbose logging on.
          09/10/2018 14:29:39  >> log verbose append:"/Users/thierry/Desktop/BCompare Mirror Backups log.txt"
          09/10/2018 14:29:39  >> 
          09/10/2018 14:29:39  >> # -------------------- Set the comparison criteria.
          09/10/2018 14:29:39  >> criteria timestamp binary
          09/10/2018 14:29:39  >> 
          09/10/2018 14:29:39  >> # -------------------- Load source and target folders.
          09/10/2018 14:29:39  >> load "/Users/thierry/PERSO/Développement/AppleScripts Perso" "sftp:// [[[path to my FTP folder]]] "
          09/10/2018 14:29:39  Connecté à ssh. [[[...]]]
          09/10/2018 14:29:40  Clé du serveur [[[...]]]
          09/10/2018 14:29:42  Authentification de Mot de passe réussie.
          09/10/2018 14:29:42  Logiciel du serveur : OpenSSH_6.7p1
          09/10/2018 14:29:42  Compression : none
          09/10/2018 14:29:42  Cryptage : aes256-ctr
          09/10/2018 14:29:42  Algorithme MAC : hmac-sha2-512
          09/10/2018 14:29:42  Connecté à ssh.[[[...]]]
          09/10/2018 14:29:42  Utilisation de la version SFTP 3.
          09/10/2018 14:29:42  Informations du serveur :
          09/10/2018 14:29:42  Dossier actuel : /home/[[[...]]]
          09/10/2018 14:29:42  Charger la comparaison : /Users/thierry/PERSO/Développement/AppleScripts Perso <-> sftp://[[[path to my FTP folder]]]
          09/10/2018 14:29:42  >> 
          09/10/2018 14:29:42  >> filter "-.DS_Store"
          09/10/2018 14:29:42  >> 
          09/10/2018 14:29:42  >> # --------- Sync the local files to the web site, creating empty folders.
          09/10/2018 14:29:42  >> sync create-empty mirror:left->right
          09/10/2018 14:29:56  Script terminé en 16,5 secondes
          "load" command take only one line:
          Code:
          >> load "/Users/thierry/PERSO/Développement/AppleScripts Perso" "sftp:// [[[path to my FTP folder]]] "
          Maybe it's a paramater problem, but I'm unable to see the problem.

          Thank you for your help.

          Comment


          • #6
            Oops, my command text file was wrong.
            Problem solved, forget my posts

            Comment


            • #7
              Great to hear. When passing around parameters, it can be tricky to troubleshoot issues like whitespace and remote location syntax. If it helps in the future, copy/paste the literal text into the script (removing the variables) and test from the command line. This way, you can better separate and determine if it's the applescript or parameters, or the base script, that is causing the issue.
              Aaron P Scooter Software

              Comment

              Working...
              X