Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Get active network service name of default route' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Get active network service name of default route
Authored by: CarlRJ on Feb 18, '05 03:57:49PM
The bit that you were missing with the newlines is that echo in bash (at least) wants a "-e" option to enable backslash escapes. This simplifies things a bit:

SERVICE_GUID=`
    echo -e "open\nget State:/Network/Global/IPv4\nd.show" |
    scutil |
    awk '/PrimaryService/{print $3}'
`

SERVICE_NAME=`
    echo -e "open\nget Setup:/Network/Service/$SERVICE_GUID\nd.show" |
    scutil |
    awk -F': ' '/UserDefinedName/{print $2}'
`

echo $SERVICE_NAME


[ Reply to This | # ]