Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 21, 2013, 10:11 AM   #1
djjasonsa
macrumors newbie
 
Join Date: Jun 2012
XCode - Cocoa-applescript question

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
djjasonsa is offline   0 Reply With Quote
Old Feb 21, 2013, 11:32 AM   #2
Red Menace
macrumors regular
 
Join Date: May 2011
Location: 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?
__________________
MacBook Pro / OS X Mavericks (10.9.2) / Xcode 5.1 / [and various (much) older stuff keeping dust off the shelves]
Red Menace is offline   0 Reply With Quote
Old Feb 21, 2013, 11:50 AM   #3
djjasonsa
Thread Starter
macrumors newbie
 
Join Date: Jun 2012
Thank you very much for the quick response.

Last edited by djjasonsa; Feb 22, 2013 at 11:08 AM.
djjasonsa is offline   0 Reply With Quote
Old Feb 21, 2013, 03:50 PM   #4
Ap0ks
macrumors regular
 
Join Date: Aug 2008
Location: 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:
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
Ap0ks is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:57 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC