Women in Technology

Hear us Roar



Article:
  Automated Backups on Tiger Using rsync
Subject:   Rsync part works fine, but what's up with Applescript?
Date:   2005-08-22 08:28:14
From:   bbushman
I'm happily able to run these scripts in the terminal window, but am trying to use them via applescript as mentioned in this article. Same error I've seen noted earlier here - the script will compile, but when I run it I get back this error "can't make current application into type string".


I've read this tech note at apple to help investigate the problem:
http://developer.apple.com/technotes/tn2002/tn2065.html#TNTAG3


Coping stategies have included:
1. keep the do shell script out of any tell blocks
2. putting it within a "tell me" block
3. running it all as one quoted command
4. storing my file paths as string vars in POSIX form (ie. "/Volumes/MyHD/Library/WebServer/etc.) and then concatenating them into the shell script
5. storing my file paths as string vars in applescript form (ie. "MyDisk:Library:WebServer:etc.) and then concatenating them into the shell script using "quoted form of the POSIX path"
6. adding /bin/bash -c to make sure they run in the same shell as my terminal instead of in sh
7. Kicking and screaming like a little girl while shouting obscenities


Also note: I've installed for now the RSyncX version, as recommended in this forum by "mechanist" on this forum. Again, works peachy in terminal, no dice in Applescript.


What am I doing wrong here, folks?


Current version of the script look like this:

-- initial vars
set buildCart to "TheLoraxG4PB-HD:Users:bbushman:DEV:brandsourcedev:website:trunk:src:cart"
set siteCart to "TheLoraxG4PB-HD:Library:WebServer:Documents:brandsourcedev"


set mySrc to quoted form of the POSIX path of buildCart
set myTgt to quoted form of the POSIX path of siteCart


-- sync 1
do shell script
"/bin/bash rsync -a --eahfs " & mySrc & myTgt & " || echo -n"



Full Threads Oldest First

Showing messages 1 through 6 of 6.

  • Rsync part works fine, but what's up with Applescript?
    2005-09-23 09:58:15  annibee [View]

    The same thing happened to me and so I took the carriage return away from the end of do shell script and then it worked. :)
  • Rsync part works fine, but what's up with Applescript?
    2005-08-22 10:51:38  bbushman [View]

    Scratch that - I put it in the middle of a function and now the applescript portion works fine... and rsync appears to be running, because it's making my error file in my user folder. But: nothing actually sync's. What could be wrong with my shell script?
    • Rsync part works fine, but what's up with Applescript?
      2005-08-22 11:26:17  bbushman [View]

      Eh. Function didn't really fix anything. All my questions still remain. :(
      • Rsync part works fine, but what's up with Applescript?
        2005-08-23 10:09:13  Corvus [View]

        mySrc & myTgt will catenate the two paths into a single huge path, which almost certainly doesn't exist, and will have no target path. You need to separate the paths with a space:

        mySrc & " " & myTgt
  • Rsync part works fine, but what's up with Applescript?
    2005-08-22 08:40:09  bbushman [View]

    PS: just read the betalogue post related to this topic (thanks pierre!) Perhaps adding /usr/local/bin/ to the beginning will help after I stop getting my other error, but for now, I'm still (of course) getting the AS error.

    Of note (which I'm assuming is obvious to anyone who knows what they are doing) is that in my event log in script editor, I"m left with this after I try running the script:

    tell current application
    do shell script current application
    "Can't make current application into type string."


    Anyone?
    • Rsync part works fine, but what's up with Applescript?
      2005-09-10 08:27:00  rharder [View]

      I had the same problem and you actually solved it for me with your last comment. I think that the problem is that the regular Apple scripters made some assumptions that would be common sense to them and left that part out. Being an ignoramous of grand proportions, I had to think through this whole problem and start from scratch. I looked at your last comment and saw "current application" and realized that the AppleScript was making the assumption that this script was to be passed to the current active app and not the terminal.

      So I looked at the dictionary from terminal and the help from AppleScript and came up with the following:

      You have to explicitly tell terminal to execute the shell script.

      e.g. (The quoted text below should be on one line.)

      tell application "Terminal"
      do shell script "ls /Users/rharder/Desktop/Test/ > /Users/rharder/Desktop/test.txt"
      quit
      end tell

      It also works with "do script" for "do shell script"....

      You can leave off the "quit" at the end, but the terminal app remains after execution.

      This solution seems to allow any number of shell scripts to be executed from iCal rather than cron which is nifty and cool and all that jazz.....

      You should be able to figure out how to marry bash, AppleScript, and iCal with this info.....

      Hope this helps, good luck,
      Ray