XCode - Cocoa-applescript question

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

  1. macrumors newbie

    Joined:
    Jun 4, 2012
    #1
    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

    Thanks
     
  2. macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    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

    Joined:
    Jun 4, 2012
    #3
    Thank you very much for the quick response.
     
  4. macrumors regular

    Joined:
    Aug 12, 2008
    Location:
    Cambridge, UK
    #4
    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:
    Code:
    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