Mac OS X: bash脚本实现添加无线SSID(Update2009-10-09)
2009-10-08 01:07
405 查看
Mac OS X: shell程序实现添加无线SSID
2009-10-08:
一个基本的实现脚本, 没有重复/删除/错误检查等处理:
2009-10-07
这个bash脚本用于企业内部规模部署的时候,无须为了添加无线网络到系统核心影像文件中而设计。
正在编写,成功可能性还是有的, 基本条件已经具备了.
2009-10-08:
一个基本的实现脚本, 没有重复/删除/错误检查等处理:
yourSSID="TEST" yourPWD="TEST" SecurityType="WEP" WEPOpenSystem=true networkUUID=`uuidgen` pwdUUID=`uuidgen` cTime=`date "+%a %b %e %H:%M:%S %Z %Y"` function addSSID_Airport_Pref { # plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "print KnownNetworks" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID dict" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:SecurityType string $SecurityType" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:SSID_STR string $yourSSID" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:'Unique Password ID' string $pwdUUID" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:'Remembered channels' array {0 integer 1}" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:_timeStamp date $cTime" sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "add KnownNetworks:$networkUUID:WEPOpenSystem bool $WEPOpenSystem" # sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "print KnownNetworks:$networkUUID" } function addPWD_SystemKeychain { # default_keychain = `security default-keychain` security default-keychain -s /Library/Keychain/System.keychain sudo security add-generic-password -a "$yourSSID" -D "AirPort network password" -s "$pwdUUID" -l "$yourSSID" -w "$yourPWD" -j "wireless_setup_v1.0" -A -U # security default-keychain -s $default_keychain security default-keychain -s "" } function addLocation { currentSet=`plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "print CurrentSet"` # currentSet=${currentSet:6} currentSet=${currentSet/////":"} # plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "print $currentSet:Network:Interface:en1:AirPort:PreferredNetworks" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0 dict" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0:SSID_STR string $yourSSID" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0:SecurityType string 'WEP'" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0:'Unique Newtork ID' string $networkUUID" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "add $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0:'Unique Password ID' string $pwdUUID" sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "set $currentSet:Network:Interface:en1:AirPort:RequireAdmin bool No" # plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "print $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0" } function CleanAll { # 1. Delete from preferences.plist currentSet=`plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "print CurrentSet"` currentSet=${AA/////":"} sudo plistbuddy /Library/Preferences/SystemConfiguration/preferences.plist -c "delete $currentSet:Network:Interface:en1:AirPort:PreferredNetworks:0" #2. Delete Airport_Pref sudo plistbuddy /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist -c "delete KnownNetworks:$networkUUID" #3. Delete Keychain security default-keychain -s /Library/Keychain/System.keychain sudo security add-generic-password -a "$yourSSID" -D "AirPort network password" -s "$pwdUUID" -l "$yourSSID" -w "$yourPWD" -j "wireless_setup_v1.0" -A -U security default-keychain -s "" } ln -f /usr/libexec/PlistBuddy /usr/sbin/plistbuddy addSSID_Airport_Pref addPWD_SystemKeychain addLocation logger "Wireless addition finished successfully."
2009-10-07
这个bash脚本用于企业内部规模部署的时候,无须为了添加无线网络到系统核心影像文件中而设计。
正在编写,成功可能性还是有的, 基本条件已经具备了.
相关文章推荐
- Mac OS X: bash脚本实现添加无线SSID(Update2009-10-09)
- Mac OS X:script实现添加无线网连接
- Mac OS X:script实现添加无线网连接
- Mac OS X: 彻底删除GeekTool(bash脚本)
- Mac OS X: 彻底删除GeekTool(bash脚本)
- ScrollView制作脚本实现图片添加
- Adobe CC update (Windows/Mac OS) 独立升级包下载
- 为MacOS X创建.bash_profile
- Adobe 2015 CC update (Windows/Mac OS) 独立升级包下载 Adobe Photoshop CC (Windows 32bit)
- iOS、Mac OS X系统中编程实现汉字转拼音的方法(超级简单)
- mac os x 添加 用户 所属 组
- JavaScript 动态添加脚本,并触发回调函数的实现代码
- linux下利用shell脚本实现添加crontab任务
- Mac OS X中正确添加环境变量的方法
- mac os x 添加自定义字体库
- 脚本实现添加用户、删除用户
- [wxWidgets]_[初级]_[Mac OS X下添加输入框的右键菜单]
- Mac OS X 10.7.2 Lion修改和添加环境变量
- Mac OS X下实现结束占用某特定端口的进程
- 如何以编程方式实现UpdatePanel中Triggers的添加