screencapture + ftp upload in AppleScript

set this_file to "/tmp/com.zuzara.desktop.png"
set ftp_host to "***"
set ftp_user to "***"
set ftp_password to "***"
set ftp_path to "/***"
set ftp_newfile to do shell script "date '+%Y%m%d%H%M.png'"
 
try
        do shell script "screencapture " & quoted form of POSIX path of this_file
        tell application "Image Events"
                launch
                set this_image to open this_file
                scale this_image to size 100 -- resize to 100px width
                save this_image with icon
                close this_image
        end tell
        tell application "Preview"
                try
                        open this_file
                        set question to display dialog "Will upload this picture!"
                        set answer to button returned of question
                        if answer is equal to "OK" then
                                -- FTP upload
                                do shell script "curl -T " & this_file & " ftp://" & ftp_user & ":" & ftp_password & "@" & ftp_host & ftp_path & ftp_newfile
                                quit -- close window 1 doesn't work...
                        end if
                on error
                        quit -- Cancel
                end try
        end tell
end try

Take a screenshot, resize it and upload it.

cron/crontab doesn’t work for this AppleScript. This error message appears in /var/log/system.log:
com.apple.launchd[1] (0x10b490.cron[9481]): Could not se
tup Mach task special port 9: (os/kern) no access

Instead of cron, we can use launchd. GUI controller is Lingon.

My hourly desktop is here.

Mac OS 10.5.8

This entry was posted in Create and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.