Text item delimiters stopped working [internal ip address]

My scripts started to behave badly recently.

I traced the problem to text item delimiter. Some or all scripts with text item delimiters dont work anymore.

This code returns {“”} even it should return my ip.

set ip_works to true
set testing to do shell script "ifconfig en1 | grep inet | cut -b \"6-20\""
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set lista to text items of testing
set AppleScript's text item delimiters to tid

In Terminal that line gives an error, so testing is “” because it an error, therefore nothing wrong with ATID

I would use

set MyIP to IPv4 address of (system info)

Have fun

In Script Editor this gives my ip:
set testing to do shell script “ifconfig en1 | grep inet | cut -b "6-20"”
–>result is my ip with leading and trailing space

But this fails in Script Editor:
set MyIP to IPv4 address of (system info)
–>missing value

I get ip correctly but with leading and trailing spaces and i need to cut those away. It used to work.

At home on my MacBook Pro I get a return with your script. At work I got an error. This work at home

set testing to do shell script "ifconfig en1 | grep 'inet ' | cut -b \"7-20\"" as string
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
set lista to text items of testing
set AppleScript's text item delimiters to tid
set MyIP to item 1 of lista

I had to add a space with the inet as I was getting two results with out it. My delimiters worked as they should. Both machines run my script, both are 10.4.9, work a G4, home a intel.

A note is at home I’ve got parallels and my method return the link IP address to parrallels (10.37.129.x) not the mac IP (192.168.1.x). Yours returns the Mac IP.

My method in Standard Addition Dictionary

I wonder how you get all IP numbers for your machine and domain names (I have a few added in NetInfo). Becuase none get 127.0.0.1

What version of the OS and Applescript do you have?

Hi cirno,

you get the internal IP address easier with

set ip_internal to do shell script ("ifconfig en1 | awk '/inet / {print $2}'")

en1 = Airport / en0 = Ethernet

set MyIP to IPv4 address of (system info) works only in 10.4 Tiger

Note that the return value is coming from the last statement, where you are setting AppleScript’s text item delimiters.