Showing all posts tagged #shell:


Install ruby on El Capitan

Posted on May 9th, 2016

wkpdf をインストールしたいので、ちゃんと ruby をインストールするところから…と思って、ここ↓の通りにやっってみました。

以下に、ログをコピペしておきます。



bisonSSD840EVO:~ stbison$ brew install git
==> Downloading https://homebrew.bintray.com/bottles/git-2.8.2.el_capitan.bottle
######################################################################## 100.0%
==> Pouring git-2.8.2.el_capitan.bottle.tar.gz
==> Caveats
The OS X keychain credential helper has been installed to:
/usr/local/bin/git-credential-osxkeychain

The "contrib" directory has been installed to:
/usr/local/share/git-core/contrib

Bash completion has been installed to:
/usr/local/etc/bash_completion.d

zsh completion has been installed to:
/usr/local/share/zsh/site-functions

Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/git
==> Summary
🍺 /usr/local/Cellar/git/2.8.2: 1,418 files, 30.5M
bisonSSD840EVO:~ stbison$ brew install readline
==> Downloading https://homebrew.bintray.com/bottles/readline-6.3.8.el_capitan.b
######################################################################## 100.0%
==> Pouring readline-6.3.8.el_capitan.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.


Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

LDFLAGS: -L/usr/local/opt/readline/lib
CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
🍺 /usr/local/Cellar/readline/6.3.8: 46 files, 2.0M
bisonSSD840EVO:~ stbison$ brew install openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2h.el_capitan.b
######################################################################## 100.0%
==> Pouring openssl-1.0.2h.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl/certs

and run
/usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺 /usr/local/Cellar/openssl/1.0.2h: 1,691 files, 12M
bisonSSD840EVO:~ stbison$ brew install ruby-build
==> Installing dependencies for ruby-build: autoconf, pkg-config
==> Installing ruby-build dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.el_capitan.bo
######################################################################## 100.0%
==> Pouring autoconf-2.69.el_capitan.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/autoconf
==> Summary
🍺 /usr/local/Cellar/autoconf/2.69: 70 files, 3.0M
==> Installing ruby-build dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1.el_capita
######################################################################## 100.0%
==> Pouring pkg-config-0.29.1.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/pkg-config/0.29.1: 10 files, 627.2K
==> Installing ruby-build
==> Downloading https://github.com/rbenv/ruby-build/archive/v20160426.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v201604
######################################################################## 100.0%
==> ./install.sh
🍺 /usr/local/Cellar/ruby-build/20160426: 215 files, 124.6K, built in 4 seconds
bisonSSD840EVO:~ stbison$ brew install rbenv
==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.0.0.el_capitan.bott
######################################################################## 100.0%
==> Pouring rbenv-1.0.0.el_capitan.bottle.tar.gz
==> Caveats
Rbenv stores data under ~/.rbenv by default. If you absolutely need to
store everything under Homebrew's prefix, include this in your profile:
export RBENV_ROOT=/usr/local/var/rbenv

To enable shims and autocompletion, run this and follow the instructions:
rbenv init
==> Summary
🍺 /usr/local/Cellar/rbenv/1.0.0: 36 files, 61.9K
bisonSSD840EVO:~ stbison$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
bisonSSD840EVO:~ stbison$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bash_profile
bisonSSD840EVO:~ stbison$ echo 'eval "$(rbenv init -)"' >> .bash_profile
bisonSSD840EVO:~ stbison$ source .bash_profile
bisonSSD840EVO:~ stbison$ rbenv install -l
Available versions:
1.8.6-p383
1.8.6-p420
1.8.7-p249
1.8.7-p302
1.8.7-p334
1.8.7-p352
1.8.7-p357
1.8.7-p358
1.8.7-p370
1.8.7-p371
1.8.7-p374
1.8.7-p375
1.9.1-p378
1.9.1-p430
1.9.2-p0
1.9.2-p180
1.9.2-p290
1.9.2-p318
1.9.2-p320
1.9.2-p326
1.9.2-p330
1.9.3-dev
1.9.3-preview1
1.9.3-rc1
1.9.3-p0
1.9.3-p125
1.9.3-p194
1.9.3-p286
1.9.3-p327
1.9.3-p362
1.9.3-p374
1.9.3-p385
1.9.3-p392
1.9.3-p429
1.9.3-p448
1.9.3-p484
1.9.3-p545
1.9.3-p547
1.9.3-p550
1.9.3-p551
2.0.0-dev
2.0.0-preview1
2.0.0-preview2
2.0.0-rc1
2.0.0-rc2
2.0.0-p0
2.0.0-p195
2.0.0-p247
2.0.0-p353
2.0.0-p451
2.0.0-p481
2.0.0-p576
2.0.0-p594
2.0.0-p598
2.0.0-p643
2.0.0-p645
2.0.0-p647
2.0.0-p648
2.1.0-dev
2.1.0-preview1
2.1.0-preview2
2.1.0-rc1
2.1.0
2.1.1
2.1.2
2.1.3
2.1.4
2.1.5
2.1.6
2.1.7
2.1.8
2.1.9
2.1.10
2.2.0-dev
2.2.0-preview1
2.2.0-preview2
2.2.0-rc1
2.2.0
2.2.1
2.2.2
2.2.3
2.2.4
2.2.5
2.3.0-dev
2.3.0-preview1
2.3.0-preview2
2.3.0
2.3.1
2.4.0-dev
jruby-1.5.6
jruby-1.6.3
jruby-1.6.4
jruby-1.6.5
jruby-1.6.5.1
jruby-1.6.6
jruby-1.6.7
jruby-1.6.7.2
jruby-1.6.8
jruby-1.7.0-preview1
jruby-1.7.0-preview2
jruby-1.7.0-rc1
jruby-1.7.0-rc2
jruby-1.7.0
jruby-1.7.1
jruby-1.7.2
jruby-1.7.3
jruby-1.7.4
jruby-1.7.5
jruby-1.7.6
jruby-1.7.7
jruby-1.7.8
jruby-1.7.9
jruby-1.7.10
jruby-1.7.11
jruby-1.7.12
jruby-1.7.13
jruby-1.7.14
jruby-1.7.15
jruby-1.7.16
jruby-1.7.16.1
jruby-1.7.16.2
jruby-1.7.17
jruby-1.7.18
jruby-1.7.19
jruby-1.7.20
jruby-1.7.20.1
jruby-1.7.21
jruby-1.7.22
jruby-1.7.23
jruby-1.7.24
jruby-1.7.25
jruby-9.0.0.0.pre1
jruby-9.0.0.0.pre2
jruby-9.0.0.0.rc1
jruby-9.0.0.0.rc2
jruby-9.0.0.0
jruby-9.0.1.0
jruby-9.0.3.0
jruby-9.0.4.0
jruby-9.0.5.0
jruby-9.1.0.0-dev
maglev-1.0.0
maglev-1.1.0-dev
maglev-2.0.0-dev
mruby-dev
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
rbx-2.2.2
rbx-2.2.3
rbx-2.2.4
rbx-2.2.5
rbx-2.2.6
rbx-2.2.7
rbx-2.2.8
rbx-2.2.9
rbx-2.2.10
rbx-2.3.0
rbx-2.4.0
rbx-2.4.1
rbx-2.5.0
rbx-2.5.1
rbx-2.5.2
rbx-2.5.3
rbx-2.5.4
rbx-2.5.5
rbx-2.5.6
rbx-2.5.7
rbx-2.5.8
rbx-2.6
rbx-2.7
rbx-2.8
rbx-2.9
rbx-2.10
rbx-2.11
rbx-2.71828182
rbx-3.0
rbx-3.1
rbx-3.2
rbx-3.3
rbx-3.4
rbx-3.5
rbx-3.6
rbx-3.7
rbx-3.8
rbx-3.9
rbx-3.10
rbx-3.11
rbx-3.12
rbx-3.13
rbx-3.14
rbx-3.15
rbx-3.16
rbx-3.17
rbx-3.18
rbx-3.19
rbx-3.20
rbx-3.21
rbx-3.22
rbx-3.23
rbx-3.24
rbx-3.25
rbx-3.26
rbx-3.27
ree-1.8.7-2011.03
ree-1.8.7-2011.12
ree-1.8.7-2012.01
ree-1.8.7-2012.02
topaz-dev
bisonSSD840EVO:~ stbison$ rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...

Installed ruby-2.3.1 to /Users/stbison/.rbenv/versions/2.3.1

bisonSSD840EVO:~ stbison$ rbenv global 2.3.1
bisonSSD840EVO:~ stbison$ rbenv versions
system
* 2.3.1 (set by /Users/stbison/.rbenv/version)
bisonSSD840EVO:~ stbison$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
bisonSSD840EVO:~ stbison$ gem install rails
Fetching: rack-1.6.4.gem (100%)
Successfully installed rack-1.6.4
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: sprockets-3.6.0.gem (100%)
Successfully installed sprockets-3.6.0
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: activesupport-4.2.6.gem (100%)
Successfully installed activesupport-4.2.6
Fetching: mini_portile2-2.0.0.gem (100%)
Successfully installed mini_portile2-2.0.0
Fetching: nokogiri-1.6.7.2.gem (100%)
Building native extensions. This could take a while...
Successfully installed nokogiri-1.6.7.2
Fetching: loofah-2.0.3.gem (100%)
Successfully installed loofah-2.0.3
Fetching: rails-html-sanitizer-1.0.3.gem (100%)
Successfully installed rails-html-sanitizer-1.0.3
Fetching: rails-deprecated_sanitizer-1.0.3.gem (100%)
Successfully installed rails-deprecated_sanitizer-1.0.3
Fetching: rails-dom-testing-1.0.7.gem (100%)
Successfully installed rails-dom-testing-1.0.7
Fetching: rack-test-0.6.3.gem (100%)
Successfully installed rack-test-0.6.3
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: builder-3.2.2.gem (100%)
Successfully installed builder-3.2.2
Fetching: actionview-4.2.6.gem (100%)
Successfully installed actionview-4.2.6
Fetching: actionpack-4.2.6.gem (100%)
Successfully installed actionpack-4.2.6
Fetching: sprockets-rails-3.0.4.gem (100%)
Successfully installed sprockets-rails-3.0.4
Fetching: thor-0.19.1.gem (100%)
Successfully installed thor-0.19.1
Fetching: railties-4.2.6.gem (100%)
Successfully installed railties-4.2.6
Fetching: bundler-1.12.3.gem (100%)
Successfully installed bundler-1.12.3
Fetching: arel-6.0.3.gem (100%)
Successfully installed arel-6.0.3
Fetching: activemodel-4.2.6.gem (100%)
Successfully installed activemodel-4.2.6
Fetching: activerecord-4.2.6.gem (100%)
Successfully installed activerecord-4.2.6
Fetching: globalid-0.3.6.gem (100%)
Successfully installed globalid-0.3.6
Fetching: activejob-4.2.6.gem (100%)
Successfully installed activejob-4.2.6
Fetching: mime-types-data-3.2016.0221.gem (100%)
Successfully installed mime-types-data-3.2016.0221
Fetching: mime-types-3.0.gem (100%)
Successfully installed mime-types-3.0
Fetching: mail-2.6.4.gem (100%)
Successfully installed mail-2.6.4
Fetching: actionmailer-4.2.6.gem (100%)
Successfully installed actionmailer-4.2.6
Fetching: rails-4.2.6.gem (100%)
Successfully installed rails-4.2.6
Parsing documentation for rack-1.6.4
Installing ri documentation for rack-1.6.4
Parsing documentation for concurrent-ruby-1.0.2
Installing ri documentation for concurrent-ruby-1.0.2
Parsing documentation for sprockets-3.6.0
Installing ri documentation for sprockets-3.6.0
Parsing documentation for thread_safe-0.3.5
Installing ri documentation for thread_safe-0.3.5
Parsing documentation for tzinfo-1.2.2
Installing ri documentation for tzinfo-1.2.2
Parsing documentation for i18n-0.7.0
Installing ri documentation for i18n-0.7.0
Parsing documentation for activesupport-4.2.6
Installing ri documentation for activesupport-4.2.6
Parsing documentation for mini_portile2-2.0.0
Installing ri documentation for mini_portile2-2.0.0
Parsing documentation for nokogiri-1.6.7.2
Installing ri documentation for nokogiri-1.6.7.2
Parsing documentation for loofah-2.0.3
Installing ri documentation for loofah-2.0.3
Parsing documentation for rails-html-sanitizer-1.0.3
Installing ri documentation for rails-html-sanitizer-1.0.3
Parsing documentation for rails-deprecated_sanitizer-1.0.3
Installing ri documentation for rails-deprecated_sanitizer-1.0.3
Parsing documentation for rails-dom-testing-1.0.7
Installing ri documentation for rails-dom-testing-1.0.7
Parsing documentation for rack-test-0.6.3
Installing ri documentation for rack-test-0.6.3
Parsing documentation for erubis-2.7.0
Installing ri documentation for erubis-2.7.0
Parsing documentation for builder-3.2.2
Installing ri documentation for builder-3.2.2
Parsing documentation for actionview-4.2.6
Installing ri documentation for actionview-4.2.6
Parsing documentation for actionpack-4.2.6
Installing ri documentation for actionpack-4.2.6
Parsing documentation for sprockets-rails-3.0.4
Installing ri documentation for sprockets-rails-3.0.4
Parsing documentation for thor-0.19.1
Installing ri documentation for thor-0.19.1
Parsing documentation for railties-4.2.6
Installing ri documentation for railties-4.2.6
Parsing documentation for bundler-1.12.3
Installing ri documentation for bundler-1.12.3
Parsing documentation for arel-6.0.3
Installing ri documentation for arel-6.0.3
Parsing documentation for activemodel-4.2.6
Installing ri documentation for activemodel-4.2.6
Parsing documentation for activerecord-4.2.6
Installing ri documentation for activerecord-4.2.6
Parsing documentation for globalid-0.3.6
Installing ri documentation for globalid-0.3.6
Parsing documentation for activejob-4.2.6
Installing ri documentation for activejob-4.2.6
Parsing documentation for mime-types-data-3.2016.0221
Installing ri documentation for mime-types-data-3.2016.0221
Parsing documentation for mime-types-3.0
Installing ri documentation for mime-types-3.0
Parsing documentation for mail-2.6.4
Installing ri documentation for mail-2.6.4
Parsing documentation for actionmailer-4.2.6
Installing ri documentation for actionmailer-4.2.6
Parsing documentation for rails-4.2.6
Installing ri documentation for rails-4.2.6
Done installing documentation for rack, concurrent-ruby, sprockets, thread_safe, tzinfo, i18n, activesupport, mini_portile2, nokogiri, loofah, rails-html-sanitizer, rails-deprecated_sanitizer, rails-dom-testing, rack-test, erubis, builder, actionview, actionpack, sprockets-rails, thor, railties, bundler, arel, activemodel, activerecord, globalid, activejob, mime-types-data, mime-types, mail, actionmailer, rails after 589 seconds
32 gems installed
bisonSSD840EVO:~ stbison$ gem install bundler
Successfully installed bundler-1.12.3
Parsing documentation for bundler-1.12.3
Done installing documentation for bundler after 6 seconds
1 gem installed
bisonSSD840EVO:~ stbison$ rbenv rehash
bisonSSD840EVO:~ stbison$ source ~/.bash_profile
bisonSSD840EVO:~ stbison$ rails -v
Rails 4.2.6

webkit2png で(HTTPがブロックされる)ATS をコントロールする方法

Posted on May 7th, 2016

webkit2png とは、Webkitを使ってコマンドラインからスクリーンショットを取得するプログラムです。
つまり、コマンドラインで、(Webkitをレンダリングエンジンとして)Webページをレンダリングした結果を画像ファイルにします。


Homebrew でインストールできます。

$ brew update
$ brew search webkit2png
$ brew install web2png

一番シンプルなSyntaxは…
$webkit2png [URL]
なので…

とやると…

... done

問題なく、カレントディレクトリにディフォルト通りの3つのファイルが出来ます。(HTTPS)

ところが、普通の http:// なURLだと…

$ webkit2png http://bison.jp/

Fetching http://bison.jp/ ...
2016-05-06 19:30:26.899 Python[88221:5471219] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
... something went wrong: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

叱られます。

「HTTP はセキュアじゃないから、App Transport Security がブロックしたよ」
「そのアプリの Info.plist に例外設定を記述するヨロシ」
とか言われてもねぇ。

そもそも App Transport Security(ATS)って何さ…な情報は↓



曰く…
"App Transport Security (以降、ATS と呼びます) は iOS 9.0 または OS X 10.11 以上で有効な機能であり、アプリとウェブサービスとの間のセキュアな接続のために利用できます。
ATS が有効の場合、HTTP での通信はできません。また、Apple が推奨する必要条件を満たさない接続は強制的に接続失敗扱いになります。例えば、Apple 推奨の要件を満たさない Web ページを WKWebView で開こうとした場合、ページのロードは失敗します。"

…(・◇・)なるほど

"Info.plist にキーと値を追加することで ATS の基本動作の例外を設定したり、ATS をオフにしたりできます。"

…(・◇・)なるほど x 2

  • 画一的に、せっかくの ATSを無効にするのは非推奨
  • Allow but Deny も Deny but Allow も指定可能

ネットを掘っても「iOS 9 と El Capitan に特有な縛りで、細かい設定は、当該アプリの Info.plist でいぢりなさい」な情報しか見つからない。


英語面倒だけれど、GitHub を掘ってみた。



/usr/local/Cellar/webkit2png/0.7/bin/webkit2png
の実行ファイルをエディタで開いて、

# Hide the dock icon (needs to run before NSApplication.sharedApplication)
AppKit.NSBundle.mainBundle().infoDictionary()['LSBackgroundOnly'] = '1'

の下に…

# Handles ATS HTTPS requirement introduced in El Cap
if options.ignore_ssl_check:
AppKit.NSBundle.mainBundle().infoDictionary()['NSAppTransportSecurity'] = dict(NSAllowsArbitraryLoads = True)

を挿入して…

--ignore-ssl-checkオプション付きで実行すればOK。

$ webkit2png --ignore-ssl-check http://example.com/

しかしコノ解決法だと、webkit2png が Update される度に、仕掛け直しなのよねきっと…orz。

その他参考

リモートマシンのGlobalIPアドレスを報告させるシェルスクリプト

Posted on August 29th, 2013

特定のリモート客先マシンから、(あるURLに)httpアクセスした結果のソースを常時ローカルホストのどこかにタイムスタンプ順に貯めておきたい…という用途で、作った シェルスクリプト。

決まった時間ごとに(cronを使って)環境変数を吐きださせるページにアクセスさせて、そのソースをストアしておくことにより、環境変数(とくに Global IP アドレス )の変化をモニターすることをイメージした。

※ IPアドレスの行だけを取り出すとかは、grep を使うとかであとでなんとでも

※ ため込む先を Dropbox 内とかにすると、当該 Dropbox アカウントを使うすべてのマシンに同様に蓄積されるので便利かも

※ cron で回すのが前提(cron が標準出力を持たないので、そこんとこ考慮済み)

こんな感じ↓

  1. wget をインスコしておく (下記例ではインスコ先は、/usr/local/bin/wget )
  2. 環境に合わせてカギ括弧([])内を書き換える(カギ括弧自体は不要)
  3. 適当な名前で、実行権限をつけて保存
  4. crontab -e で cron で回す

※ 下記例では、   (myPREFIX=hogeで、タイムスタンプ 2013/08/27 16:20:10の場合) hoge130827162010.txt というファイル名で、ローカルホストのTARGET_DIR 内に、wget の結果ソース全体が保存される。

==============

#!/bin/bash

FILE=$(mktemp -t temp [フォルダ内に生成されるファイルの接頭文字列])

/usr/local/bin/wget [URLテキスト] --output-document="$FILE"

HOST=[scpの宛先ホスト名 or IPアドレス]

USER=[ユーザー名]

PASS=[パスワード]

TARGET_DIR=[/Volumes/から始まるパス名(最後は スラッシュ付き)]

myPREFIX=[scpされるファイルの接頭文字列]

expect -c "

set timeout 10

spawn scp "$FILE" ${USER}@${HOST}:${TARGET_DIR}${myPREFIX}date +%y%m%d%H%M%S.txt

expect {

\" Are you sure you want to continue connecting (yes/no)? \" {

send \"yse\r\"

expect \"password:\"

send \"${PASS}\r\"

} \"Password:\" {

send \"${PASS}\r\"

}

}

expect {

\"denied\" { exit 2 } \

eof { exit 0 }

}

"

echo "$FILE"


bison

ICT Consultant, Solutions Developer, StudioBISON