blueutil
| 固定リンク
行番号 | ソース |
---|---|
001 | #! /usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | #https://developer.apple.com/download/all/?q=PacketLogger |
005 | #com.cocolog-nifty.quicktimer.icefloe |
006 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
007 | use AppleScript version "2.8" |
008 | use framework "Foundation" |
009 | use framework "AppKit" |
010 | use scripting additions |
011 | property refMe : a reference to current application |
012 | |
013 | try |
014 | tell application id "com.apple.PacketLogger" |
015 | activate |
016 | end tell |
017 | on error |
018 | tell application "Finder" |
019 | open location "https://developer.apple.com/download/all/?q=PacketLogger" |
020 | end tell |
021 | return "パケットロガーをインストールしてください" |
022 | end try |
023 | |
024 | |
025 | set appFileManager to refMe's NSFileManager's defaultManager() |
026 | set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask)) |
027 | set ocidLibraryDirPathURL to ocidURLsArray's firstObject() |
028 | set ocidSaveDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Logs/Apple/BluetoothReporter") |
029 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0 |
030 | ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions) |
031 | set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference) |
032 | if (item 1 of listDone) is true then |
033 | log "正常処理" |
034 | else if (item 2 of listDone) ≠ (missing value) then |
035 | log (item 2 of listDone)'s code() as text |
036 | log (item 2 of listDone)'s localizedDescription() as text |
037 | return "フォルダ作成 エラーしました" |
038 | end if |
039 | |
040 | set strDate to doGetDateNo("yyyyMMdd") as text |
041 | set strSaveFileName to (strDate & "-BluetoothReporter.pklg") |
042 | set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName) |
043 | set strSaveFilePath to ocidSaveFilePathURL's |path|() as text |
044 | # |
045 | try |
046 | set strCommandText to ("/usr/bin/sudo /System/Library/Frameworks/IOBluetooth.framework/Resources/BluetoothReporter --dumpPacketLog \"" & strSaveFilePath & "\"") as text |
047 | do shell script strCommandText |
048 | on error |
049 | return "コマンドでエラーしました" |
050 | end try |
051 | # |
052 | set aliasFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias |
053 | tell application "Finder" |
054 | open file aliasFilePath |
055 | end tell |
056 | return |
057 | |
058 | |
059 | ############################## |
060 | ### 今の日付日間 テキスト |
061 | ############################## |
062 | to doGetDateNo(argDateFormat) |
063 | ####日付情報の取得 |
064 | set ocidDate to current application's NSDate's |date|() |
065 | ###日付のフォーマットを定義 |
066 | set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init() |
067 | ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX") |
068 | set ocidTimeZone to refMe's NSTimeZone's alloc()'s initWithName:"Asia/Tokyo" |
069 | ocidNSDateFormatter's setTimeZone:(ocidTimeZone) |
070 | ocidNSDateFormatter's setDateFormat:(argDateFormat) |
071 | set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate |
072 | set strDateAndTime to ocidDateAndTime as text |
073 | return strDateAndTime |
074 | end doGetDateNo |
075 | |
076 | |
AppleScriptで生成しました |
行番号 | ソース |
---|---|
001 | #! /bin/bash |
002 | #com.cocolog-nifty.quicktimer.icefloe |
003 | # |
004 | SCRIPT_PATH="${BASH_SOURCE[0]}" |
005 | /bin/echo "実行ファイル \"$SCRIPT_PATH\"" |
006 | STR_DATE=$(/bin/date +"%Y%m%d_%H%M%S") |
007 | STAT_USR=$(/usr/bin/stat -f%Su /dev/console) |
008 | /bin/echo "STAT_USR(console): $STAT_USR" |
009 | ######################################## |
010 | ##保存先 |
011 | STR_MKDIR_PATH="/Users/${STAT_USR}/Library/Logs/Apple/BluetoothReporter" |
012 | /bin/mkdir -p "$STR_MKDIR_PATH" |
013 | /usr/sbin/chown "$STAT_USR" "$STR_MKDIR_PATH" |
014 | /bin/chmod 700 "$STR_MKDIR_PATH" |
015 | ##実行 |
016 | /usr/bin/sudo /System/Library/Frameworks/IOBluetooth.framework/Resources/BluetoothReporter --dumpPacketLog "${STR_MKDIR_PATH}/${STR_DATE}_BluetoothReporter.pklg" |
017 | ##開く |
018 | open -b com.apple.PacketLogger "${STR_MKDIR_PATH}/${STR_DATE}_BluetoothReporter.pklg" |
019 | |
020 | exit 0 |
AppleScriptで生成しました |
| 固定リンク
| 固定リンク
| 固定リンク
| 固定リンク
| 固定リンク
| 固定リンク
| 固定リンク
https://github.com/toy/blueutil
XcodeでBuildしても良いですし
makeもできます。
sh-3.2$ ./blueutil
Power: 1
Discoverable: 0
sh-3.2$
sh-3.2$ ./blueutil -H
blueutil: invalid option -- H
blueutil v2.9.0
Usage:
blueutil [options]
Without options outputs current state
-p, --power output power state as 1 or 0
-p, --power STATE set power state
-d, --discoverable output discoverable state as 1 or 0
-d, --discoverable STATE set discoverable state
--favourites, --favorites
list favourite devices
--inquiry [T] inquiry devices in range, 10 seconds duration by default excluding time for name updates
--paired list paired devices
--recent [N] list recently used devices, 10 by default, 0 to list all
--connected list connected devices
--info ID show information about device
--is-connected ID connected state of device as 1 or 0
--connect ID create a connection to device
--disconnect ID close the connection to device
--pair ID [PIN] pair with device, optional PIN of up to 16 characters will be used instead of interactive input if requested in specific pair mode
--unpair ID EXPERIMENTAL unpair the device
--add-favourite ID, --add-favorite ID
add to favourites
--remove-favourite ID, --remove-favorite ID
remove from favourites
--format FORMAT change output format of info and all listing commands
--wait-connect ID [TIMEOUT]
EXPERIMENTAL wait for device to connect
--wait-disconnect ID [TIMEOUT]
EXPERIMENTAL wait for device to disconnect
--wait-rssi ID OP VALUE [PERIOD [TIMEOUT]]
EXPERIMENTAL wait for device RSSI value which is 0 for golden range, -129 if it cannot be read (e.g. device is disconnected)
-h, --help this help
-v, --version show version
STATE can be one of: 1, on, 0, off, toggle
ID can be either address in form xxxxxxxxxxxx, xx-xx-xx-xx-xx-xx or xx:xx:xx:xx:xx:xx, or name of device to search in used devices
OP can be one of: >, >=, <, <=, =, !=; or equivalents: gt, ge, lt, le, eq, ne
PERIOD is in seconds, defaults to 1
TIMEOUT is in seconds, default value 0 doesn't add timeout
FORMAT can be one of:
default - human readable text output not intended for consumption by scripts
new-default - human readable comma separated key-value pairs (EXPERIMENTAL, THE BEHAVIOUR MAY CHANGE)
json - compact JSON
json-pretty - pretty printed JSON
Due to possible problems, blueutil will refuse to run as root user (see https://github.com/toy/blueutil/issues/41).
Use environment variable BLUEUTIL_ALLOW_ROOT=1 to override (sudo BLUEUTIL_ALLOW_ROOT=1 blueutil …).
Exit codes:
0 Success
1 General failure
64 Wrong usage like missing or unexpected arguments, wrong parameters
69 Bluetooth or interface not available
70 Internal error
71 System error like shortage of memory
75 Timeout error
sh-3.2$
sh-3.2$
| 固定リンク
Bluetoothファイル共有を停止させる
ダウンロード - bluetoothstopfileshare.scpt.zip
| 固定リンク
Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom