XCode - Cocoa-applescript question

Discussion in 'Mac Programming' started by djjasonsa, Feb 21, 2013.

  1. macrumors newbie

    Jun 4, 2012
    Hi All,

    I am trying to create a simple Cocoa-applescript, however I am having issues with getting a Text Field or Label to display the output from a shell command.

    I know this probably basic stuff but an help would be most grateful

  2. macrumors 6502

    May 29, 2011
    Littleton, Colorado, USA
    Is this an Xcode or AppleScript Editor project? Usually you would get the result from your shell script and put it into the text field using its setStringValue: method, although bindings can also be used. What have you done so far?
  3. djjasonsa, Feb 21, 2013
    Last edited: Feb 22, 2013

    thread starter macrumors newbie

    Jun 4, 2012
  4. macrumors 6502

    Aug 12, 2008
    Cambridge, UK
    The text field you're trying to populate, have you changed it's behaviour from editable to selectable or none?

    Your posted code works fine for me if the text field behaviour is set to editable. To make it work when the text field behaviour is set to selectable or none I had to put your code into the awakeFromNib method rather than an IBAction method, like so:
    on awakeFromNib()
            set ipAddress to (do shell script "ifconfig | grep -B 2 active | grep -E \"inet \" | awk {'print $2'}")
            label's setStringValue_(ipAddress)
        end awakeFromNib

Share This Page