• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: using a shell variable in an osascript line?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using a shell variable in an osascript line?


  • Subject: Re: using a shell variable in an osascript line?
  • From: RenĂ© v Amerongen <email@hidden>
  • Date: Fri, 27 Feb 2009 16:35:11 +0100

Hi,

Thanks for that part. I was also looking for this before.

About the display dialog part, I always did get "0:79: execution error: No user interaction allowed. (-1713)" back.

So I do use with your part added

osascript -e 'tell application "Finder"' -e "activate" -e "display dialog \"$(echo "$VAR1" | sed -e 's/"/\\"/g')\"" -e 'end tell'



If I may insert another question here?

How do I get the result 'button returned:OK' back or the Cancelled value?

$VAR2= osascript -e 'tell application "Finder"' -e "activate" -e "display dialog \"$(echo "$VAR1" | sed -e 's/"/\\"/g')\"" -e 'end tell'
doen't work.


On 27 feb 2009, at 16:08, Mark J. Reed wrote:

On Fri, Feb 27, 2009 at 9:45 AM, Mark J. Reed <email@hidden> wrote:
Assuming your shell is bash, this will work:

osascript -e "display dialog \"$(printf %q "$VAR1")\""

I take that back. That won't work, because printf %q backslash-escapes characters other than double quotes (including apostrophes and spaces), causing Applescript to reject the string as invalid.

So I guess we're back to escaping any quotes manually:

osascript -e "display dialog \"$(echo "$VAR1" | sed -e 's/"/\\"/g')\""

Which I verified with this:

VAR1='Fred'\''s "boo" scared me!'






--
Mark J. Reed <email@hidden>




--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: using a shell variable in an osascript line?
      • From: Axel Luttgens <email@hidden>
    • Re: using a shell variable in an osascript line?
      • From: "Mark J. Reed" <email@hidden>
    • Re: using a shell variable in an osascript line?
      • From: RenĂ© v Amerongen <email@hidden>
References: 
 >using a shell variable in an osascript line? (From: LuKreme <email@hidden>)
 >Re: using a shell variable in an osascript line? (From: Axel Luttgens <email@hidden>)
 >Re: using a shell variable in an osascript line? (From: "Mark J. Reed" <email@hidden>)
 >Re: using a shell variable in an osascript line? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: using a shell variable in an osascript line?
  • Next by Date: Re: AS + MS Word 2008 and vertical alignment in table cells
  • Previous by thread: Re: using a shell variable in an osascript line?
  • Next by thread: Re: using a shell variable in an osascript line?
  • Index(es):
    • Date
    • Thread