Admin System Information

[IOREG] IOREGをPLISTに書き出して値を取得する(NSArrayのContentsOfURLの非推奨対応)


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004# initWithContentsOfURL Deprecated対応
005(*
006ROOTがARRAY構造のPLISTは
007initWithContentsOfURLが非推奨になったため
008一般的な方法と同じでNSDATA経由で
009NSPropertyListSerializationしてPLISTとして扱う
010writeToURLも非推奨になったためNSDATAで保存する
011*)
012----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
013use AppleScript version "2.8"
014use framework "Foundation"
015use framework "AppKit"
016use scripting additions
017
018property refMe : a reference to current application
019
020##########################################
021# 【A-1】 ioregコマンドでPLISTを作成する
022log doMakeSystemProfilerPlist()
023
024##########################################
025# 【A-2】PLISTから値を取得する
026##platform-name
027set ocidIORegistryEntryName to doGetPlistKeyPath("~/Documents/Apple/IOreg/IOPlatformExpertDevice.plist", "IORegistryEntryName")
028set ocidIOPlatformSerialNumber to doGetPlistKeyPath("~/Documents/Apple/IOreg/IOPlatformExpertDevice.plist", "IOPlatformSerialNumber")
029set ocidIOPlatformUUID to doGetPlistKeyPath("~/Documents/Apple/IOreg/IOPlatformExpertDevice.plist", "IOPlatformUUID")
030#モデル名の戻り値はCFDATAなのでテキスト形式にでコード
031set ocidGetData to doGetPlistKeyPath("~/Documents/Apple/IOreg/IOPlatformExpertDevice.plist", "model")
032set ocidModel to refMe's NSString's alloc()'s initWithData:(ocidGetData) encoding:(refMe's NSUTF8StringEncoding)
033
034log ocidIORegistryEntryName as text
035log ocidIOPlatformSerialNumber as text
036log ocidIOPlatformUUID as text
037log ocidModel as text
038
039##########################################
040# 【A-2】パスとkeypath指定で値を取得する
041to doGetPlistKeyPath(argFilePath, argKeyPath)
042  #パス
043  set strFilePath to argFilePath as text
044  set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
045  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
046  set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:(false)
047  ##NSData's
048  set ocidOption to (refMe's NSDataReadingMappedIfSafe)
049  set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error| :(reference)
050  if (item 2 of listResponse) = (missing value) then
051    log "initWithContentsOfURL 正常処理"
052    set ocidReadData to (item 1 of listResponse)
053  else if (item 2 of listResponse) ≠ (missing value) then
054    log (item 2 of listResponse)'s code() as text
055    log (item 2 of listResponse)'s localizedDescription() as text
056    log "initWithContentsOfURL エラーしました"
057    return false
058  end if
059  ##NSPropertyListSerialization
060  set ocidFormat to (refMe's NSPropertyListXMLFormat_v1_0)
061  set ocidPlistSerial to (refMe's NSPropertyListSerialization)
062  set ocidOption to (refMe's NSPropertyListMutableContainersAndLeaves)
063  set listResponse to ocidPlistSerial's propertyListWithData:(ocidReadData) options:(ocidOption) format:(ocidFormat) |error| :(reference)
064  if (item 2 of listResponse) = (missing value) then
065    log "initWithContentsOfURL 正常処理"
066    set ocidPlistArray to (item 1 of listResponse)
067  else if (item 2 of listResponse) ≠ (missing value) then
068    log (item 2 of listResponse)'s code() as text
069    log (item 2 of listResponse)'s localizedDescription() as text
070    log "initWithContentsOfURL エラーしました"
071    return false
072  end if
073  #####SingleArray
074  set ocidPlistDict to ocidPlistArray's firstObject()
075  set ocidValue to (ocidPlistDict's valueForKeyPath:(argKeyPath))
076  return ocidValue
077  
078end doGetPlistKeyPath
079
080##########################################
081# 【A-1】 IOREG 第一階層のみ取得
082#"IORegistryEntry"を入れると全部取得する事になる
083property listDataTypes : {"IOPlatformExpertDevice", "IODTNVRAM", "AppleARMPE", "IOResources", "IOUserResources"} as list
084
085##########################################
086# 【A-1】のPLISTを出力する
087to doMakeSystemProfilerPlist()
088  #保存先を先に確保する
089  set appFileManager to refMe's NSFileManager's defaultManager()
090  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
091  set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
092  set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/ioreg") isDirectory:(true)
093  #フォルダを作る
094  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
095  # 777-->511 755-->493 700-->448 766-->502
096  ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
097  set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error| :(reference)
098  if (item 1 of listDone) is true then
099    log "createDirectoryAtURL 正常処理"
100    set ocidLabelNo to refMe's NSNumber's numberWithInteger:(2)
101    set listDone to (ocidSaveDirPathURL's setResourceValue:(ocidLabelNo) forKey:(refMe's NSURLLabelNumberKey) |error| :(reference))
102    if (item 1 of listDone) is true then
103      log "setResourceValue 正常処理"
104    else if (item 2 of listDone) ≠ (missing value) then
105      log (item 2 of listDone)'s code() as text
106      log (item 2 of listDone)'s localizedDescription() as text
107      return "setResourceValue エラーしました"
108    end if
109  else if (item 2 of listDone) ≠ (missing value) then
110    log (item 2 of listDone)'s code() as text
111    log (item 2 of listDone)'s localizedDescription() as text
112    log "createDirectoryAtURL エラーしました"
113    return false
114  end if
115  #ファイルを作成する
116  set ocidInfoFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("_このフォルダは削除しても大丈夫です.txt") isDirectory:(true)
117  set ocidInfoText to refMe's NSString's stringWithString:("このフォルダは削除しても大丈夫です")
118  set listDone to ocidInfoText's writeToURL:(ocidInfoFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
119  if (item 1 of listDone) is true then
120    log "writeToURL 正常終了"
121  else if (item 1 of listDone) is false then
122    log (item 2 of listDone)'s localizedDescription() as text
123    log "writeToURL保存に失敗しました"
124    return false
125  end if
126  #################################
127  #
128  repeat with itemDataType in listDataTypes
129    set ocidBaseFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(itemDataType) isDirectory:(false))
130    set ocidSaveFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:("plist"))
131    set strSaveFilePathURL to (ocidSaveFilePathURL's |path|()) as text
132    #コマンド実行
133    set strCommandText to ("/bin/zsh -c '/usr/sbin/ioreg -rd1 -c \"" & itemDataType & "\" -a  > \"" & strSaveFilePathURL & "\"'") as text
134    log strCommandText
135    try
136      do shell script strCommandText
137    on error
138      return false
139    end try
140    
141  end repeat
142  
143  return true
144end doMakeSystemProfilerPlist
AppleScriptで生成しました

|

[bash]ホスト名の取得


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002#com.cocolog-nifty.quicktimer.icefloe
003#################################################
004STR_FILE_PATH="/Library/Preferences/SystemConfiguration/preferences.plist"
005STR_LOCALHOSTNAME=$(/usr/libexec/PlistBuddy -c "Print:System:Network:HostNames:LocalHostName" "$STR_FILE_PATH")
006STR_COMPUTERNAME=$(/usr/libexec/PlistBuddy -c "Print:System:System:ComputerName" "$STR_FILE_PATH")
007STR_HOSTNAME=$(/usr/libexec/PlistBuddy -c "Print:System:System:HostName" "$STR_FILE_PATH")
008###Bonjourローカルネットワーク用
009/bin/echo "$STR_LOCALHOSTNAME"
010###MacOS用
011/bin/echo "$STR_COMPUTERNAME"
012###/bin/hostname と同等
013/bin/echo "$STR_HOSTNAME"
014
015STR_FILE_PATH="/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist"
016STR_NETBIOSNAME=$(/usr/libexec/PlistBuddy -c "Print:NetBIOSName" "$STR_FILE_PATH")
017###SMB用
018/bin/echo "$STR_NETBIOSNAME"
019
020
021exit 0
022
AppleScriptで生成しました

|

[AppleScript]ホスト名の取得


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004#
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use framework "Foundation"
008use framework "AppKit"
009use scripting additions
010
011property refMe : a reference to current application
012
013
014##########################################
015#【1】コンピューター名
016set appFileManager to refMe's NSFileManager's defaultManager()
017set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSLocalDomainMask))
018set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
019set ocidPlistFilePathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Preferences/SystemConfiguration/preferences.plist") isDirectory:(false)
020#
021set listResponse to refMe's NSDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL) |error| :(reference)
022if (item 2 of listResponse) = (missing value) then
023  log "正常処理"
024  set ocidPlistDict to (item 1 of listResponse)
025else if (item 2 of listResponse) ≠ (missing value) then
026  log (item 2 of listResponse)'s code() as text
027  log (item 2 of listResponse)'s localizedDescription() as text
028  log "エラーしました"
029  return false
030end if
031set ocidPlistFilePathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Preferences/SystemConfiguration/com.apple.smb.server.plist") isDirectory:(false)
032#
033set listResponse to refMe's NSDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL) |error| :(reference)
034if (item 2 of listResponse) = (missing value) then
035  log "正常処理"
036  set ocidPlistDictSMB to (item 1 of listResponse)
037else if (item 2 of listResponse) ≠ (missing value) then
038  log (item 2 of listResponse)'s code() as text
039  log (item 2 of listResponse)'s localizedDescription() as text
040  log "エラーしました"
041  return false
042end if
043
044###Bonjourローカルネットワーク用
045set ocidLocalHostName to (ocidPlistDict's valueForKeyPath:("System.Network.HostNames.LocalHostName"))
046###MacOS用
047set ocidComputerName to (ocidPlistDict's valueForKeyPath:("System.System.ComputerName"))
048###/bin/hostname と同等
049set ocidHostName to (ocidPlistDict's valueForKeyPath:("System.System.HostName"))
050###SMB用
051set ocidNetBIOSName to (ocidPlistDictSMB's valueForKeyPath:("NetBIOSName"))
052
053log ocidLocalHostName as text
054log ocidComputerName as text
055log ocidHostName as text
056log ocidNetBIOSName as text
057
AppleScriptで生成しました

|

[sysctl]CPUの情報を取得して表示する


あくまでも参考にしてください

【スクリプトエディタで開く】 |

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
005use AppleScript version "2.8"
006use framework "Foundation"
007use framework "AppKit"
008use scripting additions
009
010property refMe : a reference to current application
011
012
013
014set appFileManager to refMe's NSFileManager's defaultManager()
015set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
016set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
017set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/SystemCtl")
018#
019set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
020# 777-->511 755-->493 700-->448 766-->502
021ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
022set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
023if (item 1 of listDone) is true then
024  log "正常処理"
025  set aliasSaveDirPath to (ocidSaveDirPathURL's absoluteURL()) as alias
026  tell application "Finder"
027    tell folder aliasSaveDirPath
028      set comment to "このフォルダは削除しても大丈夫です"
029    end tell
030  end tell
031else if (item 2 of listDone) ≠ (missing value) then
032  log (item 2 of listDone)'s code() as text
033  log (item 2 of listDone)'s localizedDescription() as text
034  return "フォルダの作成でエラーしました"
035end if
036#戻り値の保存先
037set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("sysctl_CPU.tsv")
038#戻り値の格納用のテキスト
039set ocidSaveString to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
040#manページの記載のプロパティの数だけ繰り返し
041
042#コマンド実行して
043set strCommandText to ("/usr/sbin/sysctl -n machdep.cpu.brand_string") as text
044set strResponse to (do shell script strCommandText) as text
045#戻り値をタブ区切りテキストで保存していく
046(ocidSaveString's appendString:("CPU"))
047(ocidSaveString's appendString:("\t"))
048(ocidSaveString's appendString:(strResponse))
049(ocidSaveString's appendString:("\n"))
050#コマンド実行して
051set strCommandText to ("/usr/sbin/sysctl -n hw.activecpu") as text
052set strResponse to (do shell script strCommandText) as text
053#戻り値をタブ区切りテキストで保存していく
054(ocidSaveString's appendString:("CORE"))
055(ocidSaveString's appendString:("\t"))
056(ocidSaveString's appendString:(strResponse))
057(ocidSaveString's appendString:("\n"))
058#コマンド実行して
059set strCommandText to ("/usr/sbin/sysctl -n hw.l1dcachesize") as text
060set strResponse to (do shell script strCommandText) as text
061#戻り値をタブ区切りテキストで保存していく
062(ocidSaveString's appendString:("L1DataCache"))
063(ocidSaveString's appendString:("\t"))
064(ocidSaveString's appendString:(strResponse))
065(ocidSaveString's appendString:("\n"))
066#コマンド実行して
067set strCommandText to ("/usr/sbin/sysctl -n hw.l1icachesize") as text
068set strResponse to (do shell script strCommandText) as text
069#戻り値をタブ区切りテキストで保存していく
070(ocidSaveString's appendString:("L1InsCache"))
071(ocidSaveString's appendString:("\t"))
072(ocidSaveString's appendString:(strResponse))
073(ocidSaveString's appendString:("\n"))
074#コマンド実行して
075set strCommandText to ("/usr/sbin/sysctl -n hw.l2cachesize") as text
076set strResponse to (do shell script strCommandText) as text
077#戻り値をタブ区切りテキストで保存していく
078(ocidSaveString's appendString:("L2Cache"))
079(ocidSaveString's appendString:("\t"))
080(ocidSaveString's appendString:(strResponse))
081(ocidSaveString's appendString:("\n"))
082#コマンド実行して
083# set strCommandText to ("/usr/sbin/sysctl -n hw.l3cachesize") as text
084# set strResponse to (do shell script strCommandText) as text
085#戻り値をタブ区切りテキストで保存していく
086# (ocidSaveString's appendString:("L3Cache"))
087# (ocidSaveString's appendString:("\t"))
088# (ocidSaveString's appendString:(strResponse))
089# (ocidSaveString's appendString:("\n"))
090#コマンド実行して
091set strCommandText to ("/usr/sbin/sysctl -n hw.memsize") as text
092set numResponse to (do shell script strCommandText) as integer
093#
094set intGB to "1073741824" as integer
095set numResponse to (numResponse / intGB) as integer
096#戻り値をタブ区切りテキストで保存していく
097(ocidSaveString's appendString:("メモリ"))
098(ocidSaveString's appendString:("\t"))
099(ocidSaveString's appendString:(numResponse as text))
100(ocidSaveString's appendString:("\n"))
101
102
103#戻り値を保存
104set listDone to ocidSaveString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
105if (item 1 of listDone) is true then
106  log "正常処理"
107else if (item 2 of listDone) ≠ (missing value) then
108  log (item 2 of listDone)'s code() as text
109  log (item 2 of listDone)'s localizedDescription() as text
110  return "ファイルの保存でエラーしました"
111end if
112
113##############################
114#####ダイアログ
115##############################
116tell current application
117  set strName to name as text
118end tell
119####スクリプトメニューから実行したら
120if strName is "osascript" then
121  tell application "Finder"
122    activate
123  end tell
124else
125  tell current application
126    activate
127  end tell
128end if
129try
130  set aliasIconPath to (POSIX file "/System/Applications/Utilities/Activity Monitor.app/Contents/Resources/AppIcon.icns") as alias
131  set strMes to "CPU情報です"
132  set strSaveString to ocidSaveString as text
133  set recordResult to (display dialog strMes with title "戻り値です" default answer strSaveString buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
134on error
135  return "エラーしました"
136end try
137if (gave up of recordResult) is true then
138  return "時間切れです"
139end if
140##############################
141#####自分自身を再実行
142##############################
143if button returned of recordResult is "再実行" then
144  tell application "Finder"
145    set aliasPathToMe to (path to me) as alias
146  end tell
147  run script aliasPathToMe with parameters "再実行"
148end if
149##############################
150#####値のコピー
151##############################
152if button returned of recordResult is "クリップボードにコピー" then
153  try
154    set strText to text returned of recordResult as text
155    ####ペーストボード宣言
156    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
157    set ocidText to (refMe's NSString's stringWithString:(strText))
158    appPasteboard's clearContents()
159    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
160  on error
161    tell application "Finder"
162      set the clipboard to strText as text
163    end tell
164  end try
165end if
166
167
168return 0
AppleScriptで生成しました

|

sysctlの値を全部取得してタブ区切りテキストで保存


あくまでも参考にしてください

【スクリプトエディタで開く】 |

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
005use AppleScript version "2.8"
006use framework "Foundation"
007use scripting additions
008
009property refMe : a reference to current application
010
011
012set listOption to {"hw.activecpu", "hw.busfrequency", "hw.busfrequency_max", "hw.busfrequency_min", "hw.byteorder", "hw.cacheconfig", "hw.cachelinesize", "hw.cachesize", "hw.cpu64bit_capable", "hw.cpufamily", "hw.cpufrequency", "hw.cpufrequency_max", "hw.cpufrequency_min", "hw.cpusubtype", "hw.cputhreadtype", "hw.cputype", "hw.l1dcachesize", "hw.l1icachesize", "hw.l2cachesize", "hw.l3cachesize", "hw.logicalcpu", "hw.logicalcpu_max", "hw.memsize", "hw.ncpu", "hw.packages", "hw.pagesize", "hw.physicalcpu", "hw.physicalcpu_max", "hw.tbfrequency", "kern.argmax", "kern.bootargs", "kern.boottime", "kern.clockrate", "kern.coredump", "kern.corefile", "kern.flush_cache_on_write", "kern.hostid", "kern.hostname", "kern.job_control", "kern.maxfiles", "kern.maxfilesperproc", "kern.maxnbuf", "kern.maxproc", "kern.maxprocperuid", "kern.maxvnodes", "kern.msgbuf", "kern.nbuf", "kern.netboot", "kern.ngroups", "kern.nisdomainname", "kern.num_files", "kern.num_tasks", "kern.num_taskthreads", "kern.num_threads", "kern.num_vnodes", "kern.nx", "kern.osrelease", "kern.osrevision", "kern.ostype", "kern.osversion", "kern.posix1version", "kern.procname", "kern.safeboot", "kern.saved_ids", "kern.secure_kernel", "kern.securelevel", "kern.singleuser", "kern.sleeptime", "kern.slide", "kern.stack_depth_max", "kern.stack_size", "kern.sugid_coredump", "kern.sugid_scripts", "kern.symfile", "kern.usrstack", "kern.usrstack64", "kern.uuid", "kern.version", "kern.waketime", "machdep.cpu.address_bits.physical", "machdep.cpu.address_bits.virtual", "machdep.cpu.brand", "machdep.cpu.brand_string", "machdep.cpu.cache.L2_associativity", "machdep.cpu.cache.linesize", "machdep.cpu.cache.size", "machdep.cpu.core_count", "machdep.cpu.cores_per_package", "machdep.cpu.extfamily", "machdep.cpu.extfeature_bits", "machdep.cpu.extfeatures", "machdep.cpu.extmodel", "machdep.cpu.family", "machdep.cpu.feature_bits", "machdep.cpu.features", "machdep.cpu.leaf7_feature_bits", "machdep.cpu.leaf7_features", "machdep.cpu.logical_per_package", "machdep.cpu.max_basic", "machdep.cpu.max_ext", "machdep.cpu.microcode_version", "machdep.cpu.model", "machdep.cpu.processor_flag", "machdep.cpu.signature", "machdep.cpu.stepping", "machdep.cpu.thread_count", "machdep.cpu.tlb.data.large", "machdep.cpu.tlb.data.large_level1", "machdep.cpu.tlb.data.small", "machdep.cpu.tlb.data.small_level1", "machdep.cpu.tlb.inst.large", "machdep.cpu.tlb.inst.small", "machdep.cpu.tlb.shared", "machdep.cpu.ucupdate", "machdep.cpu.vendor", "machdep.cpu.xsave.extended_state", "machdep.tsc.deep_idle_rebase", "machdep.tsc.frequency", "machdep.tsc.nanotime.generation", "machdep.tsc.nanotime.shift", "net.inet.ip.forwarding", "net.inet.ip.portrange.first", "net.inet.ip.portrange.hifirst", "net.inet.ip.portrange.hilast", "net.inet.ip.portrange.last", "net.inet.ip.portrange.lowfirst", "net.inet.ip.portrange.lowlast", "net.inet.ip.redirect", "net.inet.ip.ttl", "net.inet.udp.checksum", "net.inet.udp.maxdgram", "vm.loadavg", "vm.swapusage", "user.bc_base_max", "user.bc_dim_max", "user.bc_scale_max", "user.bc_string_max", "user.coll_weights_max", "user.cs_path", "user.expr_nest_max", "user.line_max", "user.posix2_c_bind", "user.posix2_c_dev", "user.posix2_char_term", "user.posix2_fort_dev", "user.posix2_fort_run", "user.posix2_localedef", "user.posix2_sw_dev", "user.posix2_upe", "user.posix2_version", "user.re_dup_max", "user.stream_max", "user.tzname_max"} as list
013
014set appFileManager to refMe's NSFileManager's defaultManager()
015set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
016set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
017set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/SystemCtl")
018#
019set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
020# 777-->511 755-->493 700-->448 766-->502
021ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
022set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
023if (item 1 of listDone) is true then
024  log "正常処理"
025  set aliasSaveDirPath to (ocidSaveDirPathURL's absoluteURL()) as alias
026  tell application "Finder"
027    tell folder aliasSaveDirPath
028      set comment to "このフォルダは削除しても大丈夫です"
029    end tell
030  end tell
031else if (item 2 of listDone) ≠ (missing value) then
032  log (item 2 of listDone)'s code() as text
033  log (item 2 of listDone)'s localizedDescription() as text
034  return "フォルダの作成でエラーしました"
035end if
036#戻り値の保存先
037set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("sysctl.tsv")
038#戻り値の格納用のテキスト
039set ocidSaveString to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
040#manページの記載のプロパティの数だけ繰り返し
041repeat with itemOption in listOption
042  #コマンド実行して
043  set strCommandText to ("/usr/sbin/sysctl -n " & itemOption & "") as text
044  try
045    set strResponse to (do shell script strCommandText) as text
046    #戻り値をタブ区切りテキストで保存していく
047    (ocidSaveString's appendString:(itemOption))
048    (ocidSaveString's appendString:("\t"))
049    (ocidSaveString's appendString:(strResponse))
050    (ocidSaveString's appendString:("\n"))
051  on error
052    (ocidSaveString's appendString:(itemOption))
053    (ocidSaveString's appendString:("\t"))
054    (ocidSaveString's appendString:("値はありませんでした"))
055    (ocidSaveString's appendString:("\n"))
056  end try
057end repeat
058#戻り値を保存
059set listDone to ocidSaveString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
060if (item 1 of listDone) is true then
061  log "正常処理"
062  set aliasSaveDirPath to (ocidSaveDirPathURL's absoluteURL()) as alias
063else if (item 2 of listDone) ≠ (missing value) then
064  log (item 2 of listDone)'s code() as text
065  log (item 2 of listDone)'s localizedDescription() as text
066  return "ファイルの保存でエラーしました"
067end if
068
069tell application "Finder"
070open folder aliasSaveDirPath
071end tell
AppleScriptで生成しました

|

system infoの内容をテキスト保存する


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()


###保存先 ディレクトリ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/SystemInfo") isDirectory:true
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)

########################
#system info
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("SystemInfo.rtf") isDirectory:true
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
set recordSysInfo to (run script "return system info") as record

set recordSysInfoR to {|AppleScript version|:AppleScript version of (recordSysInfo), |AppleScript Studio version|:AppleScript Studio version of (recordSysInfo), |system version|:system version of (recordSysInfo), |short user name|:short user name of (recordSysInfo), |long user name|:long user name of (recordSysInfo), |user ID|:user ID of (recordSysInfo), |user locale|:user locale of (recordSysInfo), |home directory|:home directory of (recordSysInfo), |boot volume|:boot volume of (recordSysInfo), |computer name|:computer name of (recordSysInfo), |host name|:host name of (recordSysInfo), |IPv4 address|:IPv4 address of (recordSysInfo), |primary Ethernet address|:primary Ethernet address of (recordSysInfo), |CPU type|:CPU type of (recordSysInfo), |CPU speed|:CPU speed of (recordSysInfo), |physical memory|:physical memory of (recordSysInfo)} as record


set ocidSystemInfoDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidSystemInfoDict's setDictionary:(recordSysInfoR)

set ocidAllKeys to ocidSystemInfoDict's allKeys()

set strResponse to "" as text
repeat with itemKeys in ocidAllKeys
  set strKeys to itemKeys as text
  set strValue to (ocidSystemInfoDict's valueForKey:(itemKeys)) as text
  set strResponse to (strKeys & ":" & strValue & "\r" & strResponse) as text
end repeat


tell application "TextEdit"
activate
properties
  set objNewDoc to (make new document with properties {name:"SystemInfo", text:strResponse, path:strSaveFilePath})
  tell objNewDoc
    tell its text
properties of attribute run of every paragraph
      set its size to 20
      set its font to "Osaka-Mono"
      set its color of every paragraph to {0, 0, 0}
properties of attribute run of every paragraph
    end tell
  end tell
save objNewDoc in aliasSaveFilePath
end tell

########################
#ifconfig.me.rtf
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("ifconfig.me.rtf") isDirectory:true
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
set strCommandText to "/bin/echo $(/usr/bin/curl -s ifconfig.me)" as text
set strResponse to (do shell script strCommandText) as text

set strResponse to (strCommandText & "\r" & strResponse) as text
tell application "TextEdit"
activate
properties
  set objNewDoc to (make new document with properties {name:"ifconfig.me", text:strResponse, path:strSaveFilePath})
  tell objNewDoc
    tell its text
properties of attribute run of every paragraph
      set its size to 20
      set its font to "Osaka-Mono"
      set its color of every paragraph to {0, 0, 0}
properties of attribute run of every paragraph
    end tell
  end tell
save objNewDoc in aliasSaveFilePath
end tell


########################
######networksetup
set strResponse to "" as text
set strCommandText to "/usr/sbin/networksetup -listallnetworkservices"
set strResults to (do shell script strCommandText) as text
###戻り値を改行でリストに
set ocidListallnetworkservices to refMe's NSString's stringWithString:(strResults)
set ocidChrSet to refMe's NSCharacterSet's characterSetWithCharactersInString:("\r")
set ocidNetworkNameArray to ocidListallnetworkservices's componentsSeparatedByCharactersInSet:(ocidChrSet)
(ocidNetworkNameArray's removeObjectAtIndex:(0))
set strMacAdd to "" as text
repeat with itemNetworkName in ocidNetworkNameArray
  set strServiceName to itemNetworkName as text
  ###コマンド生成 実行
  set strCommandText to "/usr/sbin/networksetup -getinfo \"" & strServiceName & "\"" as text
  set strComResponse to (do shell script strCommandText) as text
  set strResponse to strServiceName & "\r" & strComResponse & "\r-------\r" & strResponse as text
end repeat



set ocidSaveFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:("networksetup.rtf") isDirectory:true)
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
tell application "TextEdit"
activate
properties
  set objNewDoc to (make new document with properties {name:"networksetup", text:strResponse, path:strSaveFilePath})
  tell objNewDoc
    tell its text
properties of attribute run of every paragraph
      set its size to 20
      set its font to "Osaka-Mono"
      set its color of every paragraph to {0, 0, 0}
properties of attribute run of every paragraph
    end tell
  end tell
save objNewDoc in aliasSaveFilePath
end tell




########################
(* 廃止
######airport
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("airport-i.rtf") isDirectory:true
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
set strCommandText to "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I" as text
set strResponse to (do shell script strCommandText) as text
tell application "TextEdit"
activate
properties
set objNewDoc to (make new document with properties {name:"airport-I", text:strResponse, path:strSaveFilePath})
tell objNewDoc
tell its text
properties of attribute run of every paragraph
set its size to 20
set its font to "Osaka-Mono"
set its color of every paragraph to {0, 0, 0}
properties of attribute run of every paragraph
end tell
end tell
save objNewDoc in aliasSaveFilePath
end tell
*)
########################
######getpacket
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("getpacket.rtf") isDirectory:true
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
set strCommandText to "/usr/sbin/ipconfig getpacket en0" as text
set strResponse to (do shell script strCommandText) as text
tell application "TextEdit"
activate
properties
  set objNewDoc to (make new document with properties {name:"getpacket", text:strResponse, path:strSaveFilePath})
  tell objNewDoc
    tell its text
properties of attribute run of every paragraph
      set its size to 20
      set its font to "Osaka-Mono"
      set its color of every paragraph to {0, 0, 0}
properties of attribute run of every paragraph
    end tell
  end tell
  
save objNewDoc in aliasSaveFilePath
end tell

########################
######getpacket
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("ifconfigA.rtf") isDirectory:true
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
set strCommandText to "/sbin/ifconfig -a" as text
set strResponse to (do shell script strCommandText) as text
tell application "TextEdit"
activate
properties
  set objNewDoc to (make new document with properties {name:"ifconfig", text:strResponse, path:strSaveFilePath})
  tell objNewDoc
    tell its text
properties of attribute run of every paragraph
      set its size to 20
      set its font to "Osaka-Mono"
      set its color of every paragraph to {0, 0, 0}
properties of attribute run of every paragraph
    end tell
  end tell
  
save objNewDoc in aliasSaveFilePath
end tell

########################
#arp
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("arp.rtf") isDirectory:true
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
set strCommandText to "/usr/sbin/arp -a" as text
set strResponse to (do shell script strCommandText) as text
tell application "TextEdit"
activate
properties
  set objNewDoc to (make new document with properties {name:"arp", text:strResponse, path:strSaveFilePath})
  tell objNewDoc
    tell its text
properties of attribute run of every paragraph
      set its size to 20
      set its font to "Osaka-Mono"
      set its color of every paragraph to {0, 0, 0}
properties of attribute run of every paragraph
    end tell
  end tell
  
save objNewDoc in aliasSaveFilePath
end tell


|

SystemStatsを取得してHTMLで表示


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


set strCommandText to ("/usr/sbin/systemstats --concise-dashboard tsv") as text

set strH3Text to ("SystemStats一覧") as text
set strCaption to ("SystemStats") as text
set strArticleH3 to ("SystemStatsコマンドで収集したデータ") as text


#書類フォルダ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/SystemStats")
#フォルダを作る
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#
set strDate to doGetDateNo("yyyyMMdd")
set ocidBasePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strDate) isDirectory:(false)
set ocidSaveFilePathURL to ocidBasePathURL's URLByAppendingPathExtension:("tsv")
set ocidHTMLFilePathURL to ocidBasePathURL's URLByAppendingPathExtension:("html")
#
set strResponse to (do shell script strCommandText) as text
#
set ocidReadString to refMe's NSString's stringWithString:(strResponse)
set ocidSaveString to doChgColRowTSV(ocidReadString)
##
set listDone to ocidSaveString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)

### ファイルのテキストを読み込み
set listResponse to (refMe's NSString's alloc()'s initWithContentsOfURL:(ocidSaveFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
set ocidReadString to (item 1 of listResponse)
#可変にして
set ocidLineString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
(ocidLineString's setString:(ocidReadString))
#改行をUNIXに強制
set ocidLineStringLF to (ocidLineString's stringByReplacingOccurrencesOfString:("\r\n") withString:("\n"))
set ocidLineString to (ocidLineStringLF's stringByReplacingOccurrencesOfString:("\r") withString:("\n"))
#改行毎でリストにする
set ocidCharSet to (refMe's NSCharacterSet's newlineCharacterSet)
set ocidLineArray to (ocidLineString's componentsSeparatedByCharactersInSet:(ocidCharSet))
#最初の1行目だけ別で取得しておく
set ocidFirstObjectString to ocidLineArray's firstObject()
set ocidFirstLineArray to ocidFirstObjectString's componentsSeparatedByString:("\t")

###データをHTMLに整形
########################################
#headerに渡すエレメント
set ocidSetHeaderElement to (refMe's NSXMLElement's elementWithName:("div"))
set ocidH3Element to refMe's NSXMLElement's elementWithName:("h3")
(ocidH3Element's setStringValue:(strH3Text))
(ocidSetHeaderElement's addChild:(ocidH3Element))

########################################
#footerに渡すエレメント
set ocidSetFooterElement to (refMe's NSXMLElement's elementWithName:("div"))
set ocidAElement to refMe's NSXMLElement's elementWithName:("a")
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("href") stringValue:("https://quicktimer.cocolog-nifty.com/"))
(ocidAElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("target") stringValue:("_blank"))
(ocidAElement's addAttribute:(ocidAddNode))
set strContents to ("AppleScriptで生成しました") as text
(ocidAElement's setStringValue:(strContents))
(ocidSetFooterElement's addChild:(ocidAElement))

########################################
#articleに渡すエレメント
set ocidSetArticleElement to (refMe's NSXMLElement's elementWithName:("div"))
set ocidH3Element to (refMe's NSXMLElement's elementWithName:("h3"))
set strSetValue to (strArticleH3) as text
(ocidH3Element's setStringValue:(strSetValue))
(ocidSetArticleElement's addChild:(ocidH3Element))

#########################
#テーブル部生成開始
set ocidTableElement to refMe's NSXMLElement's elementWithName:("table")
#【caption】
set ocidCaptionElement to refMe's NSXMLElement's elementWithName:("caption")
ocidCaptionElement's setStringValue:(strCaption)
ocidTableElement's addChild:(ocidCaptionElement)
#【colgroup】
set ocidColgroupElement to refMe's NSXMLElement's elementWithName:("colgroup")
#タイトル部の数だけ繰り返し
#項番部を追加する
set strFirstCol to ("LineNo") as text
ocidFirstLineArray's insertObject:(strFirstCol) atIndex:(0)
repeat with itemColName in ocidFirstLineArray
  #【col】col生成
  set ocidAddElement to (refMe's NSXMLElement's elementWithName:("col"))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
(ocidColgroupElement's addChild:(ocidAddElement))
end repeat
#テーブルエレメントに追加
ocidTableElement's addChild:(ocidColgroupElement)
#【thead】
set ocidTheadElement to refMe's NSXMLElement's elementWithName:("thead")
#TR
set ocidTrElement to refMe's NSXMLElement's elementWithName:("tr")
#タイトル部の数だけ繰り返し
repeat with itemColName in ocidFirstLineArray
  if (itemColName as text) is "LineNo" then
    #ここはTDではなくてTHを利用
    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
    ####項番処理
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
    #
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidAddElement's addAttribute:(ocidAddNode))
    #値を入れる
(ocidAddElement's setStringValue:("\"))
    #TH→TRにセット
(ocidTrElement's addChild:(ocidAddElement))
  else
    #ここはTDではなくてTHを利用
    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
    #
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidAddElement's addAttribute:(ocidAddNode))
    #値を入れる
(ocidAddElement's setStringValue:(itemColName))
    #TH→TRにセット
(ocidTrElement's addChild:(ocidAddElement))
  end if
end repeat
#TRをTHEADにセット
ocidTheadElement's addChild:(ocidTrElement)
#THEADをテーブルにセット
ocidTableElement's addChild:(ocidTheadElement)
########################################
#【tbody】
set ocidTbodyElement to refMe's NSXMLElement's elementWithName:("tbody")
###【3-4】:item
set numCntContents to (count of ocidLineArray) - 1 as integer
repeat with itemIntNo from 1 to numCntContents by 1
  set ocidLineItem to (ocidLineArray's objectAtIndex:(itemIntNo))
  #空行で終わり(TSVが改行で終わるタイプ)
  if (ocidLineItem as text) is "" then
    exit repeat
  end if
  #
  set ocidItemLineArray to (ocidLineItem's componentsSeparatedByString:("\t"))
  set numCntItemLineArray to (count of ocidItemLineArray) as integer
  ##############
  #TRの開始
  set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
  ####項番処理
  set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("項目番号:" & itemIntNo))
(ocidThElement's addAttribute:(ocidAddNode))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:("LineNo"))
(ocidThElement's addAttribute:(ocidAddNode))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidThElement's addAttribute:(ocidAddNode))
(ocidThElement's setStringValue:(itemIntNo as text))
(ocidTrElement's addChild:(ocidThElement))
  
  repeat with itemLineNo from 0 to (numCntItemLineArray - 1) by 1
    set coidFieldValue to (ocidItemLineArray's objectAtIndex:(itemLineNo))
    if itemLineNo = 0 then
      set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
      set strTitle to (ocidFirstLineArray's objectAtIndex:(itemLineNo + 1))
      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strTitle))
(ocidThElement's addAttribute:(ocidAddNode))
      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strTitle))
(ocidThElement's addAttribute:(ocidAddNode))
      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidThElement's addAttribute:(ocidAddNode))
(ocidThElement's setStringValue:(coidFieldValue))
(ocidTrElement's addChild:(ocidThElement))
    else
      set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
      set strTitle to (ocidFirstLineArray's objectAtIndex:(itemLineNo + 1))
      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strTitle))
(ocidTdElement's addAttribute:(ocidAddNode))
      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:(strTitle))
(ocidTdElement's addAttribute:(ocidAddNode))
(ocidTdElement's setStringValue:(coidFieldValue))
(ocidTrElement's addChild:(ocidTdElement))
    end if
  end repeat
(ocidTbodyElement's addChild:(ocidTrElement))
end repeat
#TBODYをテーブルにセット
ocidTableElement's addChild:(ocidTbodyElement)
#【tfoot】 TRで
set ocidTfootElement to refMe's NSXMLElement's elementWithName:("tfoot")
set ocidTrElement to refMe's NSXMLElement's elementWithName:("tr")
#項目数を取得して
set numCntCol to (count of ocidFirstLineArray) as integer
#colspan指定して1行でセット
set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("テーブルの終わり"))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("colspan") stringValue:(numCntCol as text))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("row"))
(ocidThElement's addAttribute:(ocidAddNode))
#
set strContents to ("項目数 : " & (numCntContents - 1)) as text
(ocidThElement's setStringValue:(strContents))
#THをTRにセットして
ocidTrElement's addChild:(ocidThElement)
#TRをTFOOTにセット
ocidTfootElement's addChild:(ocidTrElement)
#TFOOTをテーブルにセット
ocidTableElement's addChild:(ocidTfootElement)
#テーブルをArticleにセット
ocidSetArticleElement's addChild:(ocidTableElement)
##############################
#HTMLにする
##############################
set ocidHTML to doMakeRootElement({ocidSetHeaderElement, ocidSetArticleElement, ocidSetFooterElement})

##############################
#保存
##############################
#####保存
#読み取りやすい表示
set ocidXMLdata to ocidHTML's XMLDataWithOptions:(refMe's NSXMLNodePrettyPrint)
#保存
set listDone to ocidXMLdata's writeToURL:(ocidHTMLFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference)

####ブラウザで開く
set aliasFilePath to (ocidHTMLFilePathURL's absoluteURL()) as alias
tell application "Finder"
open location aliasFilePath
end tell

############################################################
# 基本的なHTMLの構造
(*
doMakeRootElement({argHeaderContents, argArticleContents, argFooterContents})
HTMLのBODY部
header
article
footerにそれぞれAddchildするデータをリストで渡す
戻り値はRootエレメントにセットされた
NSXMLDocumentを戻すので 保存すればOK
*)
############################################################
to doMakeRootElement({argHeaderContents, argArticleContents, argFooterContents})
  #XML初期化
  set ocidXMLDoc to refMe's NSXMLDocument's alloc()'s init()
ocidXMLDoc's setDocumentContentKind:(refMe's NSXMLDocumentHTMLKind)
  # DTD付与
  set ocidDTD to refMe's NSXMLDTD's alloc()'s init()
ocidDTD's setName:("html")
ocidXMLDoc's setDTD:(ocidDTD)
  #
  set ocidRootElement to refMe's NSXMLElement's elementWithName:("html")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("lang") stringValue:("ja")
ocidRootElement's addAttribute:(ocidAddNode)
  #
  set ocidHeadElement to refMe's NSXMLElement's elementWithName:("head")
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("title")
ocidAddElement's setStringValue:("TSV2HTML")
ocidHeadElement's addChild:(ocidAddElement)
  # http-equiv
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Type")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/html; charset=UTF-8")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Style-Type")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/css")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Script-Type")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/javascript")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("name") stringValue:("viewport")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("width=device-width, initial-scale=1.0")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("style")
ocidAddElement's setStringValue:("body {margin: 10px;background-color: #FFFFFF;}table {border-spacing: 0;caption-side: top;font-family: system-ui;}thead th {border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;word-wrap: break-word;white-space: pre-wrap;&:first-of-type {border-start-start-radius: .5em}&:last-of-type {border-start-end-radius: .5em;border-inline-end-width: 1px}}tbody td {word-wrap: break-word;border-spacing: 0;border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;word-wrap: break-word;white-space: pre-wrap;&:last-of-type {border-inline-end-width: 1px}}tbody th {border-spacing: 0;border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;word-wrap: break-word;white-space: pre-wrap;text-align: left;}tbody tr:nth-of-type(odd) {background: #F2F2F2;}.kind_string {font-size: 0.75em;}.date_string {font-size: 0.5em;}tfoot th {border: solid 1px #666666;padding: .5ch 1ch;word-wrap: break-word;white-space: pre-wrap;&:first-of-type {border-end-start-radius: .5em}&:last-of-type {border-end-end-radius: .5em;border-inline-end-width: 1px}}")
ocidHeadElement's addChild:(ocidAddElement)
ocidRootElement's addChild:(ocidHeadElement)
  #
  #ボディエレメント
  set ocidBodyElement to refMe's NSXMLElement's elementWithName:("body")
  #ヘッダー
  set ocidHeaderElement to refMe's NSXMLElement's elementWithName:("header")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("header")
ocidHeaderElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_header")
ocidHeaderElement's addAttribute:(ocidAddNode)
ocidHeaderElement's addChild:(argHeaderContents)
ocidBodyElement's addChild:(ocidHeaderElement)
  #アーティクル
  set ocidArticleElement to refMe's NSXMLElement's elementWithName:("article")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("article")
ocidArticleElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_article")
ocidArticleElement's addAttribute:(ocidAddNode)
ocidArticleElement's addChild:(argArticleContents)
ocidBodyElement's addChild:(ocidArticleElement)
  #フッター
  set ocidFooterElement to refMe's NSXMLElement's elementWithName:("footer")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("footer")
ocidFooterElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_footer")
ocidFooterElement's addAttribute:(ocidAddNode)
ocidFooterElement's addChild:(argFooterContents)
ocidBodyElement's addChild:(ocidFooterElement)
  #ボディをROOTエレメントにセット
ocidRootElement's addChild:(ocidBodyElement)
  #ROOTをXMLにセット
ocidXMLDoc's setRootElement:(ocidRootElement)
  #値を戻す
return ocidXMLDoc
end doMakeRootElement
##############################
### 今の日付日間 テキスト
##############################
to doGetDateNo(argDateFormat)
  ####日付情報の取得
  set ocidDate to current application's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
  set ocidTimeZone to refMe's NSTimeZone's alloc()'s initWithName:"Asia/Tokyo"
ocidNSDateFormatter's setTimeZone:(ocidTimeZone)
ocidNSDateFormatter's setDateFormat:(argDateFormat)
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo


##############################
### 行列入替
##############################
to doChgColRowTSV(argNsstring)
  #可変にして
  set ocidLineString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
(ocidLineString's setString:(argNsstring))
  #改行をUNIXに強制
  set ocidLineStringLF to (ocidLineString's stringByReplacingOccurrencesOfString:("\r\n") withString:("\n"))
  set ocidLineString to (ocidLineStringLF's stringByReplacingOccurrencesOfString:("\r") withString:("\n"))
  #改行毎でリストにする
  set ocidCharSet to (refMe's NSCharacterSet's newlineCharacterSet)
  set ocidTextArray to (ocidLineString's componentsSeparatedByCharactersInSet:(ocidCharSet))
  #リストの数
  set numCntArray to (count of ocidTextArray) as integer
  #出力用のテキスト
  set ocidSaveString to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
  set ocidColArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
  #1行目のテキストを取り出して
  set ocidFirsText to ocidTextArray's firstObject()
  #タブ区切りテキストにする
  set ocidFirstRowArray to ocidFirsText's componentsSeparatedByString:("\t")
  #1行目のリストの数
  set numCntFirstArray to (count of ocidFirstRowArray) as integer
  #2行目からの処理
  repeat with itemRowNo from 0 to (numCntFirstArray - 1) by 1
    #まずは1行目のデータを取り出して
    set ocidFirstItemText to (ocidFirstRowArray's objectAtIndex:(itemRowNo))
    #出力用テキストに追加しておく
(ocidSaveString's appendString:(ocidFirstItemText))
(ocidSaveString's appendString:("\t"))
    #2列目以降のデータを順に取り出して
    repeat with itemColNo from 1 to (numCntArray - 1) by 1
      #2行目以降を順番に取り出して
      set ocidLineText to (ocidTextArray's objectAtIndex:(itemColNo))
      #リストにする
      set ocidRowArray to (ocidLineText's componentsSeparatedByString:("\t"))
      #対象の列の値を取り出して
      set ocidLineItemText to (ocidRowArray's objectAtIndex:(itemRowNo))
      #追加していく
(ocidSaveString's appendString:(ocidLineItemText))
      #最後のデータにはタブ入れない
      if itemColNo < (numCntArray - 1) then
(ocidSaveString's appendString:("\t"))
      end if
    end repeat
(ocidSaveString's appendString:("\n"))
  end repeat
  
return ocidSaveString
end doChgColRowTSV






|

サポート情報(公開用)

support-sp.apple.com/sp/productの不具合に対応

【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application


###初期化
set appFileManager to refMe's NSFileManager's defaultManager()
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()


###アプリケーションディレクトリ
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationDirectory) inDomains:(refMe's NSUserDomainMask))
###URL
set ocidAppDirPathURL to ocidUserLibraryPathArray's firstObject()
set aliaAppDirPath to (ocidAppDirPathURL's absoluteURL()) as alias

#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set listUTI to {"com.apple.application-bundle"}

set aliasAppPath to (choose file with prompt "対象のアプリケーションを選んでください" default location (aliaAppDirPath) of type listUTI with invisibles without showing package contents and multiple selections allowed) as alias
###パス
set strAppPath to POSIX path of aliasAppPath
set ocidAppPathStr to refMe's NSString's stringWithString:(strAppPath)
set ocidAppPath to ocidAppPathStr's stringByStandardizingPath()
set ocidAppPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppPath) isDirectory:true)

#####################################
######ファイル保存先
#####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's firstObject()
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
###### ioreg PLIST
#####################################
set ocidIoregFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidIoregFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidIoregFilePathURL) atomically:true

###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceUUIDArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
set ocidDeviceUUID to ocidDeviceUUIDArray's firstObject()
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
set ocidDeviceEntryNameArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
set ocidDeviceEntryName to ocidDeviceEntryNameArray's firstObject()
###モデル名はNSDATAなのでテキストに解凍する
set ocidModelArray to (ocidPlistDataArray's valueForKeyPath:("IORegistryEntryChildren.model"))
set ocidModel to ocidModelArray's firstObject()
###まぁエラーになるとは思えないが
if (className() of ocidModel as text) is "NSNull" then
  set strCommandText to ("/usr/sbin/sysctl -n hw.model") as text
  set strModelStr to (do shell script strCommandText) as text
else
  set ocidModelStr to refMe's NSString's alloc()'s initWithData:(ocidModel) encoding:(refMe's NSUTF8StringEncoding)
  set strModelStr to ocidModelStr as text
end if
#####################################
######サポート情報取得
#####################################
set ocidAppBundle to refMe's NSBundle's bundleWithURL:(ocidAppPathURL)
###基本情報を取得
set ocidInfoDict to ocidAppBundle's infoDictionary
###PLISTのURLを取得して
# set ocidPlistPathURL to ocidAppBundlePathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
###読み込む
#set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
set ocidBundleName to ocidInfoDict's valueForKey:("CFBundleName")
set ocidBundleExecutable to ocidInfoDict's valueForKey:("CFBundleExecutable")
set ocidBundleDisplayName to ocidInfoDict's valueForKey:("CFBundleDisplayName")

set ocidBundleVersion to ocidInfoDict's valueForKey:("CFBundleVersion")
set ocidBuild to ocidInfoDict's valueForKey:("DTSDKBuild")
set ocidShortVersionString to ocidInfoDict's valueForKey:("CFBundleShortVersionString")
###クローム用
set ocidChannelID to ocidInfoDict's valueForKey:("KSChannelID")
###Acrobat用
set ocidTrackName to ocidInfoDict's valueForKey:("TrackName")

#####################################
###### diskutil PLIST
#####################################
set ocidDiskutilFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"diskutil.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidDiskutilFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/diskutil info -plist /" as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidDiskutilFilePathURL) atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
###ボリューム名 他
set ocidVolumeName to (ocidPlistDataArray's valueForKey:"VolumeName")
set ocidDiskUUID to (ocidPlistDataArray's valueForKey:"DiskUUID")
set ocidVolumeUUID to (ocidPlistDataArray's valueForKey:"VolumeUUID")
set ocidFilesystemName to (ocidPlistDataArray's valueForKey:"FilesystemName")
set ocidFileVault to (ocidPlistDataArray's valueForKey:"FileVault")
set ocidEncryption to (ocidPlistDataArray's valueForKey:"Encryption")
###サイズ
set ocidTotalSize to (ocidPlistDataArray's valueForKey:"TotalSize")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intTotalSize to ((ocidTotalSize's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
###残
set ocidAPFSContainerFree to (ocidPlistDataArray's valueForKey:"APFSContainerFree")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intContainerFree to ((ocidAPFSContainerFree's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
########################
##メモリサイズを調べる
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set realMemoryByte to ocidProcessInfo's physicalMemory() as real
set realGB to "1073741824" as real
set intPhysicalMemory to realMemoryByte / realGB as integer
##ユーザー情報
set ocidEnvDict to ocidProcessInfo's environment()
set strHOME to (ocidEnvDict's valueForKey:"HOME") as text
set strUSER to (ocidEnvDict's valueForKey:"USER") as text
set strLOGNAME to (ocidEnvDict's valueForKey:"LOGNAME") as text
set strTMPDIR to (ocidEnvDict's valueForKey:"TMPDIR") as text
########################
###OSのバージョン
set ocidSystemPathArray to (appFileManager's URLsForDirectory:(refMe's NSCoreServiceDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidCoreServicePathURL to ocidSystemPathArray's firstObject()
set ocidPlistFilePathURL to ocidCoreServicePathURL's URLByAppendingPathComponent:"SystemVersion.plist"
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
set strOSversion to (ocidPlistDict's valueForKey:("ProductVersion")) as text
########################
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text
(*
###モデル名を取得 configCode
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
####
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
set ocidComponentArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
##
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:(strConfigCode)
ocidComponentArray's addObject:(ocidQueryItem)
#####
set ocidLocale to refMe's NSLocale's currentLocale()
set ocidLocaleID to ocidLocale's localeIdentifier()
set ocidQueryItem to (refMe's NSURLQueryItem's alloc()'s initWithName:("lang") value:(ocidLocaleID))
(ocidComponentArray's addObject:(ocidQueryItem))
###検索クエリーとして追加
(ocidComponents's setQueryItems:(ocidComponentArray))
####コンポーネントをURLに展開
set ocidNewURL to ocidComponents's |URL|()
log ocidNewURL's absoluteString() as text

###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###configCodeからモデル名を取得
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
set strConfigCode to ocidConfigCode's stringValue as text
*)
####CPUタイプ
set strCPU to CPU type of (system info) as text
log strConfigCode as text

########################
###ダイアログ
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias


set strAns to ("モデル名:" & strConfigCode & "\r") as text
set strAns to (strAns & "OSバージョン:" & strOSversion & "\r") as text
set strAns to (strAns & "物理メモリ:" & intPhysicalMemory & " GB\r") as text
set strAns to (strAns & "CFBundleExecutable:" & ocidBundleExecutable & "\r") as text
set strAns to (strAns & "ShortVersion:" & ocidShortVersionString & "\r") as text



#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

###ダイアログ
set recordResult to (display dialog "ioreg 戻り値です\rコピーしてメールかメッセージを送ってください\r※相手が信用出来ない場合は削除" with title "サポート情報" default answer strAns buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" cancel button "キャンセル" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  set strText to text returned of recordResult as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
end if

|

[まとめ]System Informationとsystem_profiler

system_profilerはDataTypeを指定すれば
それほど時間はかからない

ダウンロード - system20information.zip


DataTypeはコマンドから取得できる
/usr/sbin/system_profiler -listDataTypes


SPParallelATADataType
SPUniversalAccessDataType
SPSecureElementDataType
SPApplicationsDataType
SPAudioDataType
SPBluetoothDataType
SPCameraDataType
SPCardReaderDataType
SPiBridgeDataType
SPDeveloperToolsDataType
SPDiagnosticsDataType
SPDisabledSoftwareDataType
SPDiscBurningDataType
SPEthernetDataType
SPExtensionsDataType
SPFibreChannelDataType
SPFireWireDataType
SPFirewallDataType
SPFontsDataType
SPFrameworksDataType
SPDisplaysDataType
SPHardwareDataType
SPInstallHistoryDataType
SPInternationalDataType
SPLegacySoftwareDataType
SPNetworkLocationDataType
SPLogsDataType
SPManagedClientDataType
SPMemoryDataType
SPNVMeDataType
SPNetworkDataType
SPPCIDataType
SPParallelSCSIDataType
SPPowerDataType
SPPrefPaneDataType
SPPrintersSoftwareDataType
SPPrintersDataType
SPConfigurationProfileDataType
SPRawCameraDataType
SPSASDataType
SPSerialATADataType
SPSPIDataType
SPSmartCardsDataType
SPSoftwareDataType
SPStartupItemDataType
SPStorageDataType
SPSyncServicesDataType
SPThunderboltDataType
SPUSBDataType
SPNetworkVolumeDataType
SPWWANDataType
SPAirPortDataType

|

[ダイアログ表示]SPHardwareDataType


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

#####################################
######コマンド実行
#####################################
set strCommandText to "/usr/sbin/system_profiler SPHardwareDataType -xml"
set strReadString to (do shell script strCommandText) as text

#####################################
######PLIST をDictで処理
#####################################
###戻り値をストリングに
set ocidReadString to refMe's NSString's stringWithString:(strReadString)
###NSDATAにして
set ocidReadData to ocidReadString's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###PLISTに変換
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:(ocidReadData) options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
set ocidPlistDataArray to item 1 of listResults
##ここがroot
set ocidPlistRoot to ocidPlistDataArray's firstObject()
##item0
set ocidRootDict to (refMe's NSDictionary's alloc()'s initWithDictionary:(ocidPlistRoot))
##ITEMS
set ocidItemsArray to (ocidRootDict's objectForKey:("_items"))
##item0
set ocidItemsDict to ocidItemsArray's firstObject()
##キーの値をリストで取り
set ocidAllKeys to ocidItemsDict's allKeys()
set strOutPutText to ("") as text
repeat with itemAllKeys in ocidAllKeys
  set strAllKey to itemAllKeys as text
  set strValue to (ocidItemsDict's valueForKey:(itemAllKeys)) as text
  set strOutPutText to (strOutPutText & strAllKey & ": " & strValue & "\n") as text
end repeat


#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias
###ダイアログ
set recordResult to (display dialog " 戻り値です\rコピーしてメールかメッセージを送ってください" with title "SPHardwareDataType" default answer strOutPutText buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  try
    set strText to text returned of recordResult as text
    ####ペーストボード宣言
    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
    set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
  on error
    tell application "Finder"
      set the clipboard to strTitle as text
    end tell
  end try
end if


|

その他のカテゴリー

Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation 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 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 Apple AppleScript AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Audio AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Diff AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript Droplet AppleScript eMail AppleScript Encode % AppleScript Encode Decode AppleScript Encode UTF8 AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript Guide AppleScript HTML AppleScript HTML Entity AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim AppleScript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript Leading Zero AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript Mail AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Messages AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSArray Sort AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFileManager enumeratorAtURL AppleScript NSFont AppleScript NSFontManager AppleScript NSGraphicsContext AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSpoint AppleScript NSPredicate AppleScript NSPrintOperation AppleScript NSRange AppleScript NSRect AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSURLSession AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotation AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFImageRep AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photoshop AppleScript Pictures AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript Swift AppleScript System Events AppleScript System Events Plist AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text MD AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML savedSearch AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript XMP AppleScript YouTube Applications CityCode github iPhone List lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom Windows zoom