日本語の情報がなかったので今後使うと思うのでメモ。
OSXのキーチェーンアクセスに秘密メモという項目に設定を持たせ、
スクリプトの中から使いたかったのです。
- キーチェーンアクセスの秘密メモに項目を登録。(ここではmy_secret_info)
- コマンドラインから秘密メモを取り出す。
security find-generic-password -C note -s my_secret_info -w > my_secret.txt
- 取り出した情報はバイナリ文字列かつXMLなので、メモ本体を取り出す。
sample.rb
require 'rexml/document'
str = open("my_secret.txt").read
doc = REXML::Document.new str.split.pack("H*")
puts doc.root.elements["dict/string"].text
stackoverflowからの簡易説明でした。(あちらはPythonだったので)
http://stackoverflow.com/questions/22370552/keychain-services-secure-notes