• 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: Sat, 28 Feb 2009 00:48:27 +0100

Hi,

On 27 feb 2009, at 21:34, Matthew Smith wrote:

on 27/02/2009 17:43 , LuKreme at email@hidden wrote:

I have a shell variable that I set to the output of a shell command

VAR1=`tail -1 /var/log/maillog`

and then I use VAR1 in the shell script for various things.

Then, at some point, I want to use that VAR1 in an osascript line, maybe
something like:


   osascript -e "display dialog $VAR1"

this doesn't work, however. the variable is transient in nature, so I can't
simply redo the assignment as a do shell script.


Do I have to do

   osascript -e "display dialog (do shell script \"echo $VAR1\")"

which while it works, is fugly to behold, or is there a better option I'm
missing?

Try: osascript -e 'display dialog system attribute "VAR1"'

For some reason I can't use display dialog. I get "no user interaction
allowed".


Maybe you did mis it. I wrote 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'

Try to use tell application "Finder". HTH


--
Matthew Smith


_______________________________________________
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
References: 
 >Re: using a shell variable in an osascript line? (From: Matthew Smith <email@hidden>)

  • Prev by Date: Re: using a shell variable in an osascript line?
  • Next by Date: Re: using a shell variable in an osascript line?
  • 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