Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

djjasonsa

macrumors newbie
Original poster
Jun 4, 2012
3
0
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
 
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?
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.