Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the '10.5: Take and upload screenshots via Automator' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Take and upload screenshots via Automator
Authored by: regulus on Jun 16, '09 12:17:21PM
Here's a little applescript to do the same thing without the automator and shell script effort. It has error checking too. Note: if you don't want to store your password in clear text in the script (not very secure!) you can look at post #5 here for a method of using the keychain to store/restore the password:
-- variables
set ftpHost to ""
set ftpUserName to "ftp user name"
set ftpPassword to "ftp password"
set ftpRemotePath to "/tmpScreen.png"
set screencapturePath to (path to desktop folder as text) & "tmpScreen.png"
set webImageURL to ""

-- take the screenshot
do shell script "/usr/sbin/screencapture " & quoted form of POSIX path of screencapturePath

-- ftp upload
set ftpURL to "ftp://" & ftpUserName & ":" & ftpPassword & "@" & ftpHost & ftpRemotePath
set hadSuccess to false
  tell application "URL Access Scripting" to upload file screencapturePath to ftpURL replacing yes with binhexing
  set hadSuccess to true
on error theError number errorNumber
  if errorNumber is not -128 then
    tell me
      display dialog "There was an error:" & return & return & theError & return & "Error Number: " & errorNumber as text buttons {"OK"} default button 1 with icon stop
    end tell
  end if
end try

-- delete the screenshot
do shell script "rm " & quoted form of POSIX path of screencapturePath

-- open the website file
if hadSuccess then open location webImageURL
robg adds: edited to show code in fixed-width box.
Edited on Feb 19, '10 10:43:21AM by robg

[ Reply to This | # ]