pecet
pecet

Reputation: 125

Switch Network Link Conditioner profiles from console/script

Is it possible to switch Network Link Conditioner profiles from MacOS command line or by using script, and generally is it possible to automate NLC, if so how?

Thank you in advance.

Upvotes: 1

Views: 2362

Answers (2)

Pierz
Pierz

Reputation: 8118

The Network Link Conditioner tool is essentially a GUI to control dummynet rules which can be controlled on the command line using dnctl and pfctl (or ipfw on older versions of MacOS and BSD) as described by Jonathan Levin's informative *OS Internals book.

So instead of using NLC you could just directly use dnctl to create/modify rules on the command line - for some examples see the dnctl and pfctl man pages and a related question.

Upvotes: 4

Balaji Dubey
Balaji Dubey

Reputation: 446

The following applescript works well in OS X El Capitan.You have to pass a system attribute:

set mode to system attribute "mode"
tell application "System Preferences"
activate
set current pane to pane "com.apple.Network-Link-Conditioner"
end tell

tell application "System Events"
 tell process "System Preferences"
  tell window "Network Link Conditioner"
    click button "ON"
    tell group 1
        click pop up button 1
        click menu item mode of menu 1 of pop up button 1
    end tell
  end tell
 end tell
end tell

Syntax to pass system attribute (from command line):

mode=DSL osascript yourFile.applescript

Replace DSL by network link conditioner profiles (3G, Wifi, Edge)

Upvotes: 3

Related Questions