script does not work when run from LB

Sharing and discussing custom actions for LaunchBar
Post Reply
iRounak
Rank 4
Rank 4
Posts: 191
Joined: Fri Oct 23, 2009 7:11 pm
Contact:

script does not work when run from LB

Post by iRounak » Wed Jul 16, 2014 5:22 am

I wrote a script to send currently viewed image in Safari to my iPhone via Messages app.

The script works nicely from Script Editor. When run from LB, it gives error:
Can’t make "Macintosh HD:Users:irounak:Documents:temp:thisTempImage.jpg" into type reference.


Any workarounds?

Code: Select all

try
   try
      do shell script "rm /Users/irounak/Documents/temp/thisTempImage.jpg"
   end try
   tell application "Safari" to set theURL to URL of front document
   
   set thefile to do shell script "curl -o  /Users/irounak/Documents/temp/thisTempImage.jpg " & theURL
   set thefile to (path to documents folder) & "temp:thisTempImage.jpg" as string
   
   repeat 5 times
      
      if exists thefile then
         tell application "Messages"
            
            send file thefile to buddy "Rounak Cell"
            exit repeat
         end tell
      end if
      
   end repeat
   
on error e
   tell me to activate
   display dialog e
end try



LB5, 10.9

Post Reply