Admin

[BASH]NTP設定

基本的にはMobileconfigを使った方がいいかなと
[mobileconfig]日付時刻の同期設定
https://quicktimer.cocolog-nifty.com/icefloe/2023/10/post-9f7f0a.html

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
# 基本的にはMobileconfigを使って設定した方がBetter
#################################################
##設定するNTPサーバー
STR_NTP_SERVER="ntp.nict.jp"
#################################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行ユーザー(whoami): $USER_WHOAMI"
if [ "$USER_WHOAMI" != "root" ]; then
/bin/echo "このスクリプトを実行するには管理者権限が必要です。"
/bin/echo "sudo で実行してください"
  ### path to me
SCRIPT_PATH="${BASH_SOURCE[0]}"
/bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
/bin/echo "↑を実行してください"
exit 1
else
  ###STAT
STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
/bin/echo "STAT_USR(console): $STAT_USR"
fi

########################################
##
STR_COMMAND_RESPONSE=$(/usr/bin/sntp "$STR_NTP_SERVER")
if [[ $STR_COMMAND_RESPONSE == *"failure"* ]]; then
echo "Error: サーバーに接続できません 'failure'処理を中止しました"
exit 1
fi
##
STR_DATE_NO=$(/bin/date +'%Y%m%d%H%M%S')
STR_BACKUP_PATH="/private/etc/ntp.conf.""$STR_DATE_NO"
###バックアップを作成
/usr/bin/sudo /usr/bin/touch "/private/etc/ntp.conf"
/usr/bin/sudo /usr/bin/ditto "/private/etc/ntp.conf" "$STR_BACKUP_PATH"
###設定内容を作って
STR_SETTING=$(/bin/echo "server ""$STR_NTP_SERVER")
###書き込み
/bin/echo "$STR_SETTING" | /usr/bin/sudo /usr/bin/tee "/private/etc/ntp.conf" >/dev/null

exit 0


|

CFBundleNameの取得


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

#!/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 "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

set strBaseURL to "https://app.jamfnow.com/applications/add/search/"

###################################
#####入力ダイアログ
###################################
#####ダイアログを前面に
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 appFileManager to refMe's NSFileManager's defaultManager()
set ocidAppDirPathURLArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidAppDirPathURL to ocidAppDirPathURLArray's firstObject()
set aliasDefaultLocation to (ocidAppDirPathURL's absoluteURL()) as alias
set listUTI to {"com.apple.application-bundle"}
set strPromptText to "アプリケーションを選んでください" as text
set strMesText to "アプリケーションを選んでください" as text

set listAliasFilePath to (choose file strMesText with prompt strPromptText default location (aliasDefaultLocation) of type listUTI with invisibles and multiple selections allowed without showing package contents) as list

repeat with itemFilePath in listAliasFilePath
  set aliasFilePath to itemFilePath as alias
  set strFilePath to (POSIX path of aliasFilePath) as text
  set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:true)
  set ocidPlistPathURL to (ocidFilePathURL's URLByAppendingPathComponent:("Contents/Info.plist"))
  ####
  set listReadPlistData to (refMe's NSMutableDictionary's dictionaryWithContentsOfURL:(ocidPlistPathURL) |error|:(reference))
  set ocidPlistDict to item 1 of listReadPlistData
  set ocidCfbundlName to (ocidPlistDict's valueForKey:"CFBundleName")
  set strCfbundlName to ocidCfbundlName as text
  
  set strURL to ("" & strBaseURL & strCfbundlName & "/all") as text
  ##URLのオープンの仕方はお好みで
  tell application "Finder"
open location strURL
  end tell
  
end repeat






|

[Bash]JRE8アップデート


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

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
# Microsoft Edgeのアップデート用
########################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行したユーザーは:$USER_WHOAMI"
if [ "$USER_WHOAMI" != "root" ]; then
  /bin/echo "このスクリプトを実行するには管理者権限が必要です。"
  /bin/echo "sudo で実行してください"
  ### path to me
  SCRIPT_PATH="${BASH_SOURCE[0]}"
  /bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
  /bin/echo "↑を実行してください"
  exit 1
else
  ###実行しているユーザー名
  CURRENT_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
  /bin/echo "実行ユーザー:" "$CURRENT_USER"
fi
###コンソールユーザー CONSOLE_USERはFinderでログインしていないと出ない
CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
if [ -z "$CONSOLE_USER" ]; then
  /bin/echo "コンソールユーザーが無い=電源入れてログインウィンドウ状態"
else
  /bin/echo "コンソールユーザー:" "$CONSOLE_USER"
fi
########################################
##OS
PLIST_PATH="/System/Library/CoreServices/SystemVersion.plist"
STR_OS_VER=$(/usr/bin/defaults read "$PLIST_PATH" ProductVersion)
/bin/echo "OS VERSION :" "$STR_OS_VER"
STR_MAJOR_VERSION="${STR_OS_VER%%.*}"
/bin/echo "STR_MAJOR_VERSION :" "$STR_MAJOR_VERSION"
STR_MINOR_VERSION="${STR_OS_VER#*.}"
/bin/echo "STR_MINOR_VERSION :" "$STR_MINOR_VERSION"

########################################
###ローカルのユーザーアカウントを取得
TEXT_RESULT=$(/usr/bin/dscl localhost -list /Local/Default/Users PrimaryGroupID | /usr/bin/awk '$2 == 20 { print $1 }')
###リストにする
read -d '\\n' -r -a LIST_USER <<<"$TEXT_RESULT"
###リスト内の項目数
NUM_CNT=${#LIST_USER[@]}
/bin/echo "ユーザー数:" "$NUM_CNT"
########################################
STR_DEVICE_UUID=$(/usr/sbin/ioreg -c IOPlatformExpertDevice | grep IOPlatformUUID | awk -F'"' '{print $4}')
/bin/echo "デバイスUUID: " "$STR_DEVICE_UUID"
###各ユーザーの最終ログアウト日
for ITEM_LIST in "${LIST_USER[@]}"; do
  STR_CHECK_File_PATH="/Users/${ITEM_LIST}/Library/Preferences/ByHost/com.apple.loginwindow.$STR_DEVICE_UUID.plist"
  STR_LAST_LOGOUT=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S" "$STR_CHECK_File_PATH")
  /bin/echo "ユーザー$ITEM_LIST の最終ログアウト日: " "$STR_LAST_LOGOUT"
done
########################################
##デバイス
#起動ディスクの名前を取得する
for ITEM_LIST in "${LIST_USER[@]}"; do
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/com.apple.diskutil.plist"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/sbin/diskutil info -plist / >"/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/com.apple.diskutil.plist"
  STARTUPDISK_NAME=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/defaults read "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/com.apple.diskutil.plist" VolumeName)
done
/bin/echo "ボリューム名:" "$STARTUPDISK_NAME"
########################################
###ダウンロード起動時に削除する項目
for ITEM_LIST in "${LIST_USER[@]}"; do
  USER_TEMP_DIR=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/mktemp -d)
  /bin/echo "起動時に削除されるディレクトリ:" "$USER_TEMP_DIR"
done
########################################
##基本メンテナンス
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/chmod 700 "/Users/${ITEM_LIST}/Library"
  ##ライブラリの不可視属性を解除
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/chflags nohidden "/Users/${ITEM_LIST}/Library"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/SetFile -a v "/Users/${ITEM_LIST}/Library"
  ## Managed Itemsフォルダを作る
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/chmod 755 "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/sbin/chown "${ITEM_LIST}" "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "/Users/${ITEM_LIST}/Library/Managed Items/.localized"
  ##
  /bin/chmod 777 "/Users/${ITEM_LIST}/Library/Caches"
  /bin/chmod 777 /Users/"${ITEM_LIST}"/Library/Caches/*
  ##
  /bin/chmod -Rf 755 "/Users/${ITEM_LIST}/Library/Fonts"
  /usr/sbin/chown -Rf "${ITEM_LIST}" "/Users/${ITEM_LIST}/Library/Fonts"
  ##
  /bin/echo "ライブラリチェックDONE:" "${ITEM_LIST}"
done
########################################
## HOME
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  ############
  LIST_SUB_DIR_NAME=("Applications" "Desktop" "Developer" "Documents" "Downloads" "Groups" "Library" "Movies" "Music" "Pictures" "Public" "Sites" "bin")
  for ITEM_DIR_NAME in "${LIST_SUB_DIR_NAME[@]}"; do
    /bin/mkdir -p "/Users/${ITEM_LIST}/${ITEM_DIR_NAME}"
    /usr/sbin/chown "${ITEM_LIST}" "/Users/${ITEM_LIST}/${ITEM_DIR_NAME}"
    /usr/bin/touch "/Users/${ITEM_LIST}/${ITEM_DIR_NAME}/.localized"
    /usr/sbin/chown "${ITEM_LIST}" "/Users/${ITEM_LIST}/${ITEM_DIR_NAME}/.localized"
    /bin/chmod -N "/Users/${ITEM_LIST}/${ITEM_DIR_NAME}"
    /bin/chmod 700 "/Users/${ITEM_LIST}/${ITEM_DIR_NAME}"
    /bin/chmod +a "group:everyone deny delete" "/Users/${ITEM_LIST}/${ITEM_DIR_NAME}"
  done

  ############
  ## 他ユーザー閲覧可
  #
  /bin/chmod 755 "/Users/${ITEM_LIST}/Sites"
  /usr/bin/chgrp www "/Users/${ITEM_LIST}/Sites"
  #
  /bin/chmod 755 "/Users/${ITEM_LIST}/Public"
  #
  /bin/chmod 750 "/Users/${ITEM_LIST}/Groups"

  ##全ローカルユーザーに対して実施したい処理があれば追加する
  /bin/echo "ユーザーディレクトリチェックDONE" "${ITEM_LIST}"
done
########################################
## Public
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  /bin/chmod 755 "/Users/${ITEM_LIST}/Public"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Drop Box"
  /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  /bin/chmod 733 "$STR_CHECK_DIR_PATH"
  /bin/chmod -N "$STR_CHECK_DIR_PATH"
  /bin/chmod +a "group:everyone deny delete" "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Documents"
  /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /bin/chmod -N "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Downloads"
  /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /bin/chmod -N "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Favorites"
  /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /bin/chmod -N "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Groups"
  /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/chgrp -Rf staff "$STR_CHECK_DIR_PATH"
  /bin/chmod 770 "$STR_CHECK_DIR_PATH"
  /bin/chmod -N "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Shared"
  /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/chgrp -Rf staff "$STR_CHECK_DIR_PATH"
  /bin/chmod 750 "$STR_CHECK_DIR_PATH"
  /bin/chmod -N "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Guest"
  /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  /bin/chmod 777 "$STR_CHECK_DIR_PATH"
  /bin/chmod -N "$STR_CHECK_DIR_PATH"
  /bin/chmod +a "group:everyone allow read,write,append,delete,list,search,add_file,add_subdirectory,delete_child,file_inherit,directory_inherit" "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Shared Items"
  /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  /bin/chmod 775 "$STR_CHECK_DIR_PATH"
  /bin/chmod -N "$STR_CHECK_DIR_PATH"
  /bin/echo "パブリックチェックDONE" "${ITEM_LIST}"
done
########################################
## Applications
########################################
## Applications
for ITEM_LIST in "${LIST_USER[@]}"; do
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Applications"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  ##サブフォルダを作る
  LIST_SUB_DIR_NAME=("Demos" "Desktop" "Developer" "Documents" "Downloads" "Favorites" "Groups" "Library" "Movies" "Music" "Pictures" "Public" "Shared" "Sites" "System" "Users" "Utilities")
  ##リストの数だけ処理
  for ITEM_DIR_NAME in "${LIST_SUB_DIR_NAME[@]}"; do
    /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH/$ITEM_DIR_NAME"
    /bin/chmod 700 "$STR_CHECK_DIR_PATH/${ITEM_DIR_NAME}"
    /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/$ITEM_DIR_NAME/.localized"
  done
done
########################################
##シンボリックリンクを作る
if [[ ! -e "/Users/$CURRENT_USER/Applications/Applications" ]]; then
  /bin/ln -s "/Applications" "/Users/$CURRENT_USER/Applications/Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/Finder Applications" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Finder.app/Contents/Applications" "/Users/$CURRENT_USER/Applications/Utilities/Finder Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/Finder Libraries" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries" "/Users/$CURRENT_USER/Applications/Utilities/Finder Libraries"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/System Applications" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Applications" "/Users/$CURRENT_USER/Applications/Utilities/System Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/System Utilities" ]]; then
  /bin/ln -s "/Applications/Utilities" "/Users/$CURRENT_USER/Applications/Utilities/System Utilities"
fi

########################################
##ここから本処理
###ダウンロード>>起動時に削除する項目
  USER_TEMP_DIR=$(/usr/bin/sudo -u "$CONSOLE_USER" /usr/bin/mktemp -d)
###CPUタイプでの分岐
ARCHITEC=$(/usr/bin/arch)
/bin/echo "Running on $ARCHITEC"
if [ "$ARCHITEC" == "arm64" ]; then
  ###ARM用のダウンロードURL
  STR_URL="https://javadl.oracle.com/webapps/download/AutoDL?BundleId=248764_8c876547113c4e4aab3c868e9e0ec572"
  ###ファイル名を取得
  DL_FILE_NAME=$(/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' "$STR_URL" | awk -F"/" '{print $NF}' | cut -d'=' -f1 | cut -d'&' -f1)
  /bin/echo "DL_FILE_NAME:$DL_FILE_NAME"
  ###ダウンロード
  if ! /usr/bin/curl -L -o "$USER_TEMP_DIR/$DL_FILE_NAME" "$STR_URL" --connect-timeout 20; then
    /bin/echo "ファイルのダウンロードに失敗しました HTTP1.1で再トライします"
    if ! /usr/bin/curl -L -o "$USER_TEMP_DIR/$DL_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20; then
      /bin/echo "ファイルのダウンロードに失敗しました"
      exit 1
    fi
  fi
else
  ###INTEL用のダウンロードURL
  STR_URL="https://javadl.oracle.com/webapps/download/AutoDL?BundleId=248766_8c876547113c4e4aab3c868e9e0ec572"
  ###ファイル名を取得
  DL_FILE_NAME=$(/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' "$STR_URL" | awk -F"/" '{print $NF}' | cut -d'=' -f1 | cut -d'&' -f1)
  /bin/echo "DL_FILE_NAME:$DL_FILE_NAME"
  ###ダウンロード
  if ! /usr/bin/curl -L -o "$USER_TEMP_DIR/$DL_FILE_NAME" "$STR_URL" --connect-timeout 20; then
    /bin/echo "ファイルのダウンロードに失敗しました HTTP1.1で再トライします"
    if ! /usr/bin/curl -L -o "$USER_TEMP_DIR/$DL_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20; then
      /bin/echo "ファイルのダウンロードに失敗しました"
      exit 1
    fi
  fi
fi


##全ユーザー実行可能にしておく
/bin/chmod 755 "$USER_TEMP_DIR/$DL_FILE_NAME"
/bin/echo "ダウンロードOK"

############################################################
######### インストール DMG In PKG
/bin/echo "インストール開始:DMG in PKG:" "$CURRENT_USER"
###マウントポイント
STR_MOUNTPOINT_PATH="$USER_TEMP_DIR/MountPoint/JRE"
###マウントポイント作成
/bin/mkdir -p "$STR_MOUNTPOINT_PATH"
/bin/chmod 777 "$STR_MOUNTPOINT_PATH"
###ディスクをマウント マウントポイント指定
/usr/bin/hdiutil attach "$USER_TEMP_DIR/$DL_FILE_NAME" -noverify -nobrowse -noautoopen -mountpoint "$STR_MOUNTPOINT_PATH"
###インストールPKGパス
STR_PKG_PATH="$STR_MOUNTPOINT_PATH/Java 8 Update 381.app/Contents/Resources/JavaAppletPlugin.pkg"
/usr/sbin/installer -pkg "$STR_PKG_PATH" -target / -dumplog -allowUntrusted -lang ja
sleep 2
###ディスクをアンマウント
/usr/bin/hdiutil detach "$STR_MOUNTPOINT_PATH" -force

exit 0


|

[予約語]SystemFolderLocalizations

『.localized』に対応する名称

Plist情報:SystemFolderLocalizations.plist
項番キーの名前キーの値
1Saved Searches保存済みの検索条件
2Relocated Items場所が変更された項目
3Deleted Users削除されたユーザ
4Favoritesよく使う項目
5Publicパブリック
6CompositionsCompositions
7Groupsグループ
8Documents書類
9Sitesサイト
10Networkネットワーク
11Systemシステム
12My Networkマイネットワーク
13Shared Items共有項目
14My Applicationsマイアプリケーション
15Moviesムービー
16Mail Downloadsメールダウンロード
17Serversサーバ
18Serverサーバ
19Picturesピクチャ
20Shared共有
21Recovered files修復されたファイル
22Configuration構成
23Securityセキュリティ
24Incompatible Software互換性のないソフトウェア
25Utilitiesユーティリティ
26Desktopデスクトップ
27Musicミュージック
28Faxesファクス
29Downloadsダウンロード
30Guestゲスト
31Usersユーザ
32Drop Boxドロップボックス
33Web ReceiptsWeb受信
34Libraryライブラリ
35Localローカル
36Applicationsアプリケーション
合計36項目

|

[NSFilePosixPermissions]Permission MODE 8進数 10進数 一覧



ダウンロード - dec_oct_mode.numbers.zip





NSUmask

Umask

Mode

Mode

Dec

Oct

Oct

Dec

0

000

777

511

1

001

776

510

2

002

775

509

3

003

774

508

4

004

773

507

5

005

772

506

6

006

771

505

7

007

770

504

8

010

767

503

9

011

766

502

10

012

765

501

11

013

764

500

12

014

763

499

13

015

762

498

14

016

761

497

15

017

760

496

16

020

757

495

17

021

756

494

18

022

755

493

19

023

754

492

20

024

753

491

21

025

752

490

22

026

751

489

23

027

750

488

24

030

747

487

25

031

746

486

26

032

745

485

27

033

744

484

28

034

743

483

29

035

742

482

30

036

741

481

31

037

740

480

32

040

737

479

33

041

736

478

34

042

735

477

35

043

734

476

36

044

733

475

37

045

732

474

38

046

731

473

39

047

730

472

40

050

727

471

41

051

726

470

42

052

725

469

43

053

724

468

44

054

723

467

45

055

722

466

46

056

721

465

47

057

720

464

48

060

717

463

49

061

716

462

50

062

715

461

51

063

714

460

52

064

713

459

53

065

712

458

54

066

711

457

55

067

710

456

56

070

707

455

57

071

706

454

58

072

705

453

59

073

704

452

60

074

703

451

61

075

702

450

62

076

701

449

63

077

700

448

64

100

677

447

65

101

676

446

66

102

675

445

67

103

674

444

68

104

673

443

69

105

672

442

70

106

671

441

71

107

670

440

72

110

667

439

73

111

666

438

74

112

665

437

75

113

664

436

76

114

663

435

77

115

662

434

78

116

661

433

79

117

660

432

80

120

657

431

81

121

656

430

82

122

655

429

83

123

654

428

84

124

653

427

85

125

652

426

86

126

651

425

87

127

650

424

88

130

647

423

89

131

646

422

90

132

645

421

91

133

644

420

92

134

643

419

93

135

642

418

94

136

641

417

95

137

640

416

96

140

637

415

97

141

636

414

98

142

635

413

99

143

634

412

100

144

633

411

101

145

632

410

102

146

631

409

103

147

630

408

104

150

627

407

105

151

626

406

106

152

625

405

107

153

624

404

108

154

623

403

109

155

622

402

110

156

621

401

111

157

620

400

112

160

617

399

113

161

616

398

114

162

615

397

115

163

614

396

116

164

613

395

117

165

612

394

118

166

611

393

119

167

610

392

120

170

607

391

121

171

606

390

122

172

605

389

123

173

604

388

124

174

603

387

125

175

602

386

126

176

601

385

127

177

600

384

128

200

577

383

129

201

576

382

130

202

575

381

131

203

574

380

132

204

573

379

133

205

572

378

134

206

571

377

135

207

570

376

136

210

567

375

137

211

566

374

138

212

565

373

139

213

564

372

140

214

563

371

141

215

562

370

142

216

561

369

143

217

560

368

144

220

557

367

145

221

556

366

146

222

555

365

147

223

554

364

148

224

553

363

149

225

552

362

150

226

551

361

151

227

550

360

152

230

547

359

153

231

546

358

154

232

545

357

155

233

544

356

156

234

543

355

157

235

542

354

158

236

541

353

159

237

540

352

160

240

537

351

161

241

536

350

162

242

535

349

163

243

534

348

164

244

533

347

165

245

532

346

166

246

531

345

167

247

530

344

168

250

527

343

169

251

526

342

170

252

525

341

171

253

524

340

172

254

523

339

173

255

522

338

174

256

521

337

175

257

520

336

176

260

517

335

177

261

516

334

178

262

515

333

179

263

514

332

180

264

513

331

181

265

512

330

182

266

511

329

183

267

510

328

184

270

507

327

185

271

506

326

186

272

505

325

187

273

504

324

188

274

503

323

189

275

502

322

190

276

501

321

191

277

500

320

192

300

477

319

193

301

476

318

194

302

475

317

195

303

474

316

196

304

473

315

197

305

472

314

198

306

471

313

199

307

470

312

200

310

467

311

201

311

466

310

202

312

465

309

203

313

464

308

204

314

463

307

205

315

462

306

206

316

461

305

207

317

460

304

208

320

457

303

209

321

456

302

210

322

455

301

211

323

454

300

212

324

453

299

213

325

452

298

214

326

451

297

215

327

450

296

216

330

447

295

217

331

446

294

218

332

445

293

219

333

444

292

220

334

443

291

221

335

442

290

222

336

441

289

223

337

440

288

224

340

437

287

225

341

436

286

226

342

435

285

227

343

434

284

228

344

433

283

229

345

432

282

230

346

431

281

231

347

430

280

232

350

427

279

233

351

426

278

234

352

425

277

235

353

424

276

236

354

423

275

237

355

422

274

238

356

421

273

239

357

420

272

240

360

417

271

241

361

416

270

242

362

415

269

243

363

414

268

244

364

413

267

245

365

412

266

246

366

411

265

247

367

410

264

248

370

407

263

249

371

406

262

250

372

405

261

251

373

404

260

252

374

403

259

253

375

402

258

254

376

401

257

255

377

400

256

256

400

377

255

257

401

376

254

258

402

375

253

259

403

374

252

260

404

373

251

261

405

372

250

262

406

371

249

263

407

370

248

264

410

367

247

265

411

366

246

266

412

365

245

267

413

364

244

268

414

363

243

269

415

362

242

270

416

361

241

271

417

360

240

272

420

357

239

273

421

356

238

274

422

355

237

275

423

354

236

276

424

353

235

277

425

352

234

278

426

351

233

279

427

350

232

280

430

347

231

281

431

346

230

282

432

345

229

283

433

344

228

284

434

343

227

285

435

342

226

286

436

341

225

287

437

340

224

288

440

337

223

289

441

336

222

290

442

335

221

291

443

334

220

292

444

333

219

293

445

332

218

294

446

331

217

295

447

330

216

296

450

327

215

297

451

326

214

298

452

325

213

299

453

324

212

300

454

323

211

301

455

322

210

302

456

321

209

303

457

320

208

304

460

317

207

305

461

316

206

306

462

315

205

307

463

314

204

308

464

313

203

309

465

312

202

310

466

311

201

311

467

310

200

312

470

307

199

313

471

306

198

314

472

305

197

315

473

304

196

316

474

303

195

317

475

302

194

318

476

301

193

319

477

300

192

320

500

277

191

321

501

276

190

322

502

275

189

323

503

274

188

324

504

273

187

325

505

272

186

326

506

271

185

327

507

270

184

328

510

267

183

329

511

266

182

330

512

265

181

331

513

264

180

332

514

263

179

333

515

262

178

334

516

261

177

335

517

260

176

336

520

257

175

337

521

256

174

338

522

255

173

339

523

254

172

340

524

253

171

341

525

252

170

342

526

251

169

343

527

250

168

344

530

247

167

345

531

246

166

346

532

245

165

347

533

244

164

348

534

243

163

349

535

242

162

350

536

241

161

351

537

240

160

352

540

237

159

353

541

236

158

354

542

235

157

355

543

234

156

356

544

233

155

357

545

232

154

358

546

231

153

359

547

230

152

360

550

227

151

361

551

226

150

362

552

225

149

363

553

224

148

364

554

223

147

365

555

222

146

366

556

221

145

367

557

220

144

368

560

217

143

369

561

216

142

370

562

215

141

371

563

214

140

372

564

213

139

373

565

212

138

374

566

211

137

375

567

210

136

376

570

207

135

377

571

206

134

378

572

205

133

379

573

204

132

380

574

203

131

381

575

202

130

382

576

201

129

383

577

200

128

384

600

177

127

385

601

176

126

386

602

175

125

387

603

174

124

388

604

173

123

389

605

172

122

390

606

171

121

391

607

170

120

392

610

167

119

393

611

166

118

394

612

165

117

395

613

164

116

396

614

163

115

397

615

162

114

398

616

161

113

399

617

160

112

400

620

157

111

401

621

156

110

402

622

155

109

403

623

154

108

404

624

153

107

405

625

152

106

406

626

151

105

407

627

150

104

408

630

147

103

409

631

146

102

410

632

145

101

411

633

144

100

412

634

143

99

413

635

142

98

414

636

141

97

415

637

140

96

416

640

137

95

417

641

136

94

418

642

135

93

419

643

134

92

420

644

133

91

421

645

132

90

422

646

131

89

423

647

130

88

424

650

127

87

425

651

126

86

426

652

125

85

427

653

124

84

428

654

123

83

429

655

122

82

430

656

121

81

431

657

120

80

432

660

117

79

433

661

116

78

434

662

115

77

435

663

114

76

436

664

113

75

437

665

112

74

438

666

111

73

439

667

110

72

440

670

107

71

441

671

106

70

442

672

105

69

443

673

104

68

444

674

103

67

445

675

102

66

446

676

101

65

447

677

100

64

448

700

77

63

449

701

76

62

450

702

75

61

451

703

74

60

452

704

73

59

453

705

72

58

454

706

71

57

455

707

70

56

456

710

67

55

457

711

66

54

458

712

65

53

459

713

64

52

460

714

63

51

461

715

62

50

462

716

61

49

463

717

60

48

464

720

57

47

465

721

56

46

466

722

55

45

467

723

54

44

468

724

53

43

469

725

52

42

470

726

51

41

471

727

50

40

472

730

47

39

473

731

46

38

474

732

45

37

475

733

44

36

476

734

43

35

477

735

42

34

478

736

41

33

479

737

40

32

480

740

37

31

481

741

36

30

482

742

35

29

483

743

34

28

484

744

33

27

485

745

32

26

486

746

31

25

487

747

30

24

488

750

27

23

489

751

26

22

490

752

25

21

491

753

24

20

492

754

23

19

493

755

22

18

494

756

21

17

495

757

20

16

496

760

17

15

497

761

16

14

498

762

15

13

499

763

14

12

500

764

13

11

501

765

12

10

502

766

11

9

503

767

10

8

504

770

7

7

505

771

6

6

506

772

5

5

507

773

4

4

508

774

3

3

509

775

2

2

510

776

1

1

511

777

0

0



|

[spctl]developer team ID

$HOME/Library/Group Containers との紐付けを確認するときに

spctl -a -vv -t install "/Applications/Adobe Acrobat Reader DC.app"

spctl -a -vv -t install /Volumes/Snagit/Snagit 2022.app

|

[IP]IPアドレスとホスト名を取得する(グローバル・アドレス)

ダウンロード - dnsjson.scpt.zip

#!/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.4"
use framework "Foundation"
use scripting additions
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSDictionary : a reference to objMe's NSDictionary
property objNSMutableString : a reference to objMe's NSMutableString
property objNSJSONSerialization : a reference to objMe's NSJSONSerialization


set listDNS to {"cloudflare", "google"}
try
set objResponse to (choose from list listDNS with title "選んでください" with prompt "DNSを選んでください" default items (item 2 of listDNS) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed)
on error
log "エラーしました"
return
end try
if objResponse is false then
return
end if

set theResponse to (objResponse) as text



####自分のグローバルIPアドレスの取得
set strGetIpCommandText to ("/usr/bin/curl 'https://api.ipify.org?format=text'") as text
set strIP to (do shell script strGetIpCommandText) as text
###NSString
set ocidIP to objNSString's stringWithString:strIP
###ドットを区切り文字にリスト化
set ocidIpNSArray to ocidIP's componentsSeparatedByString:"."
###逆順用のリストを用意して
set ocidIpReverse to objNSMutableString's |string|()
###逆順リストに追加していきく
ocidIpReverse's appendString:(ocidIpNSArray's objectAtIndex:3)
ocidIpReverse's appendString:"."
ocidIpReverse's appendString:(ocidIpNSArray's objectAtIndex:2)
ocidIpReverse's appendString:"."
ocidIpReverse's appendString:(ocidIpNSArray's objectAtIndex:1)
ocidIpReverse's appendString:"."
ocidIpReverse's appendString:(ocidIpNSArray's objectAtIndex:0)

######IPアドレスからホスト名を取得
if theResponse is "cloudflare" then
###コマンド整形
####cloudflare-dns.com
set strDnsCommandText to ("/usr/bin/curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=" & (ocidIpReverse as text) & ".in-addr.arpa&type=PTR'") as text
####コマンド実行
set jsonDnsQuery to (do shell script strDnsCommandText) as text
else
####dns.google
set strDnsCommandText to ("/usr/bin/curl -X GET -H 'Content-Type: application/json' 'https://dns.google/resolve?name=" & (ocidIpReverse as text) & ".in-addr.arpa&type=PTR&cd=true&do=true'") as text
####コマンド実行
set jsonDnsQuery to (do shell script strDnsCommandText) as text
end if


###戻り値のJSONをレコードに格納
set ocidResJson to (objNSJSONSerialization's JSONObjectWithData:((objNSString's stringWithString:jsonDnsQuery)'s dataUsingEncoding:(objMe's NSUTF8StringEncoding)) options:0 |error|:(missing value))

####データ取得確認
set numStatus to (Status of ocidResJson) as text
if numStatus is not "0" then
log "JSONデータの取得に失敗しました"
return
error number -128
end if

####Authorityを取得
set ocidAnswerArray to ocidResJson's Answer
####Answer』はリストArrayなので1つ目を取得する
set ocidAuthorityDictionary to ocidAnswerArray's objectAtIndex:0
####↑で取得したディレクトリの『data』を取得-->ホスト名
set ocidHostName to ocidAuthorityDictionary's valueForKey:"data"

log className() of ocidHostName as text
log ocidHostName as text

#####ダイアログを出す
set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns" as alias
set theResponse to "" & (ocidIpReverse as text) & "\r" & (ocidHostName as text) & "" as text

display dialog "IP:" & (ocidIpReverse as text) & "\rHostName:" & (ocidHostName as text) & "" with title "グローバル情報" default answer theResponse buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 10 without hidden answer


return

|

[WIFI]WIFIの電源のOFF-ON

ダウンロード - wifioffon.scpt.zip

#!/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 scripting additions

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSArray : a reference to objMe's NSArray

#####ネットワークサービスの一覧
set strNetWorkServices to (do shell script "/usr/sbin/networksetup -listallnetworkservices") as text
set ocidNetWorkServices to objNSString's stringWithString:strNetWorkServices
set ocidNSArrayNetWorkServices to ocidNetWorkServices's componentsSeparatedByString:"\r"
ocidNSArrayNetWorkServices's removeObjectAtIndex:0

try
set objResponse to (choose from list (ocidNSArrayNetWorkServices as list) with title "選んでください" with prompt "WIFIポートを選んでください" default items (item 2 of (ocidNSArrayNetWorkServices as list)) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed)
on error
log "エラーしました"
return
end try
if objResponse is false then
return
end if
set strNetWorkName to (objResponse) as text

#####ハードウェアポートの一覧
set strHardWarePorts to (do shell script "/usr/sbin/networksetup -listallhardwareports") as text
set ocidHardWarePorts to objNSString's stringWithString:strHardWarePorts
set ocidNSArrayNetWorkPorts to ocidHardWarePorts's componentsSeparatedByString:"\r\r"

#####ポート分繰り返し
repeat with objNetWorkPorts in ocidNSArrayNetWorkPorts
set strNetWorkPorts to objNetWorkPorts as text
if strNetWorkPorts contains strNetWorkName then
#####文字列を整形
set ocidNetWorkPorts to (objNSString's stringWithString:strNetWorkPorts)
set ocidSelectNetWorkPorts to (ocidNetWorkPorts's componentsSeparatedByString:"\r")
set ocidDeviceLinet to (ocidSelectNetWorkPorts's objectAtIndex:1)
#####デバイス名を取得
set ocidSearchString to (objNSString's stringWithString:"Device: ")
set ocidReplacementString to (objNSString's stringWithString:"")
set ocidDeviceName to (ocidDeviceLinet's stringByReplacingOccurrencesOfString:ocidSearchString withString:ocidReplacementString)

end if
end repeat
####対象のデバイスの電源を取得
set strWifiStatus to (do shell script "/usr/sbin/networksetup -getairportpower '" & ocidDeviceName & "'") as text
set ocidWifiStatus to (objNSString's stringWithString:strWifiStatus)
set ocidArrayWifiStatus to (ocidWifiStatus's componentsSeparatedByString:": ")
set ocidWifiStatus to (ocidArrayWifiStatus's objectAtIndex:1)

####OFF-ON処理
if (ocidWifiStatus as text) contains "On" then
try
do shell script "/usr/sbin/networksetup -setairportpower '" & strNetWorkName & "' off"
end try
else
try
do shell script "/usr/sbin/networksetup -setairportpower '" & strNetWorkName & "' on"
end try
end if


return

|

[jamfNow用]デバイス情報のアプリケーションをJamfNowのAPPに登録するときの補助

Apple ConfiguratorでiPhoneにインストール済みのアプリの一覧から
書き出したデータを使って
20220509090124_1280x481x1440

20220509081636_1280x593x1440
https://app.jamfnow.com/applications
に登録するときに使った補助ツール
100ケとか手作業じゃナニなんで

ダウンロード - jamfnowe799bbe98cb2.zip




カンマ区切りの場合
#!/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 scripting additions


set strBaseURL to "https://app.jamfnow.com/applications/add/search/"


tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat


set aliasFile to (choose file with prompt "ファイルを選んでください" default location (path to desktop folder from user domain) of type {"public.comma-separated-values-text"} with invisibles and showing package contents without multiple selections allowed) as alias

set strFilePath to POSIX path of aliasFile as text



set strCommandText to ("cat \"" & strFilePath & "\"")

set strReadData to (do shell script strCommandText) as text

set AppleScript's text item delimiters to "\r"
set listReadData to every text item of strReadData
set AppleScript's text item delimiters to ""


repeat with objReadData in listReadData
set strReadData to objReadData as text
set AppleScript's text item delimiters to ","
set listLineData to every text item of strReadData
set AppleScript's text item delimiters to ""
set strAppName to text item 11 of listLineData as text
set AppleScript's text item delimiters to " ("
set listAppName to every text item of strAppName
set AppleScript's text item delimiters to ""
set strAppNameText to text item 1 of listAppName as text


-----Chromeで開く
tell application "Google Chrome"
activate
tell window 1
set active tab index to 1
make new tab
tell active tab
set URL to ("" & strBaseURL & strAppNameText & "/all")
end tell
end tell
end tell

delay 10


end repeat




to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace



plistの場合
#!/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 scripting additions


set strBaseURL to "https://app.jamfnow.com/applications/add/search/"


tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat


set aliasFile to (choose file with prompt "ファイルを選んでください" default location (path to desktop folder from user domain) of type {"com.apple.property-list"} with invisibles and showing package contents without multiple selections allowed) as alias

set strFilePath to POSIX path of aliasFile as text


tell application "System Events"
tell property list file strFilePath
tell property list item 1
tell property list item "apps"
set numAppCnt to (count of every property list item) as number
end tell
end tell
end tell
end tell

set numCntChk to 0

repeat numAppCnt times
set numCntChk to numCntChk + 1


tell application "System Events"
tell property list file strFilePath
tell property list item 1
tell property list item "apps"
tell property list item numCntChk
tell property list item "name"
set strAppName to value
end tell
end tell
end tell
end tell
end tell
end tell

-----Chromeで開く
tell application "Google Chrome"
activate
tell window 1
set active tab index to 1
make new tab
tell active tab
set URL to ("" & strBaseURL & strAppName & "/all")
end tell
end tell
end tell

delay 10


end repeat




to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace


|

[Apple Configurator]iPhoneのアプリの情報を取得する

前提情景
『Apple Configurator 2』がインストール済みなこと
Apple Configurator2で『Apple Configurator』メニューから自動化ツールをインストール済みな事
iOSデバイスiPhomeが有線(ケーブル)で接続済みなこと

ダウンロード - cfgutil.scpt.zip



#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# "実行後しばらく時間がかかります30秒"
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

log "実行後しばらく時間がかかります30秒"

set strCommandText to "date +%s"
set numDate to do shell script strCommandText
##フォルダを作って
set strCommandText to "mkdir -pm 777 /tmp/" & numDate & "" as text
do shell script strCommandText
##ファイル名を定義
set strCNFGdeviceECIDsPlistFilePath to ("/tmp/" & numDate & "/CNFGdeviceECIDs.plist") as text
##
set strCommandText to "'/Applications/Apple Configurator.app/Contents/MacOS/cfgutil' --format plist -f get name ECID installedApps > " & strCNFGdeviceECIDsPlistFilePath & "" as text
do shell script strCommandText

set listDevName to {}
tell application "System Events"
tell property list file strCNFGdeviceECIDsPlistFilePath
tell property list item "Output"
set listDict to name of (every property list item)
set numDictCnt to count of listDict
repeat with objDic in listDict
set objDic to objDic as text
if objDic is not "Errors" then
tell property list item objDic
tell property list item "name"
set strDevName to value
copy strDevName to the end of listDevName
end tell
end tell
end if
end repeat
end tell
end tell
end tell


try
set objResponse to (choose from list listDevName with title "選んでください" with prompt "データを取得するデバイスを選んでください" default items (item 1 of listDevName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed)
on error
log "エラーしました"
return
end try
if objResponse is false then
return
end if
set theResponse to (objResponse) as text

tell application "System Events"
tell property list file strCNFGdeviceECIDsPlistFilePath
tell property list item "Output"
set listDict to name of (every property list item)
repeat with objDic in listDict
set objDic to objDic as text
if objDic is not "Errors" then
tell property list item objDic
tell property list item "name"
set strDevName to value
end tell
if strDevName is theResponse then
tell property list item "ECID"
set strECID to value
end tell
end if
end tell
end if
end repeat
end tell
end tell
end tell

set strText to ""

tell application "System Events"
tell property list file strCNFGdeviceECIDsPlistFilePath
tell property list item "Output"
tell property list item strECID
tell property list item "installedApps"
set listAppArray to (every property list item)
repeat with objAppArray in listAppArray

set listValue to every property list item of objAppArray
set strDisplayName to value of item 1 of listValue
set strBundleIdentifier to value of item 3 of listValue


set strText to strText & strDisplayName & "\r" & strBundleIdentifier & "\r\r" as text


end repeat
end tell
end tell
end tell
end tell
end tell



###ダイアログを出して
set aliasIconPath to POSIX file "/System/Applications/App Store.app/Contents/Resources/AppIcon.icns" as alias
set theResponse to 2 as number
try
set objResponse to (display dialog "bundleId+ArtistId" with title "bundleId+ArtistId" default answer strText buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 10 without hidden answer)
on error
log "エラーしました"
return
end try
if true is equal to (gave up of objResponse) then



###保存先フォルダ指定
set aliasSaveDir to (path to desktop folder from user domain) as alias
###ファイル名指定
set theFileName to ("" & strECID & ".rtf") as text


#############ここから本処理
##保存先フォルダのUNIXパス
set pathSaveDir to POSIX path of aliasSaveDir as text

##ファイル名までをパスにしておく
set pahtSaveFilePath to (pathSaveDir & theFileName) as text

##ファイル名までのエイリアスパス
set aliasSaveFilePath to POSIX file pahtSaveFilePath

##テンポラリファイル用のファイル名を生成
set strDate to (do shell script "date '+%s'")

##テンポラリファイル用ファイルのパス
set strTmpFilePath to "/tmp/" & strDate & ".txt"

##テンポラリファイルを作成
do shell script "touch " & strTmpFilePath & ""

##テンポラリファイルをTRF形式に変換
do shell script "/usr/bin/textutil -convert rtf " & strTmpFilePath & " -output " & pahtSaveFilePath & ""
delay 1
##########ファイルを開いて上書き保存して新規書類確定
tell application "TextEdit"
activate
open aliasSaveFilePath
tell document 1
set its text to strText
save in aliasSaveFilePath
end tell
end tell

end if
if "OK" is equal to (button returned of objResponse) then
set theResponse to (text returned of objResponse) as text
else
return "キャンセル"
end if

###ファイルを開く
tell application "Finder"
set aliasPlist to POSIX file strCNFGdeviceECIDsPlistFilePath as alias
open aliasPlist
end tell

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes 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 Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray 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 NSFont AppleScript NSFontManager 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 NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange 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 NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events 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 Sort AppleScript Sound AppleScript Spotlight