Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

curlコマンドで標準入力の結果を受け取る

curlコマンドはPOSTアクションを実行できます。
これを使って簡易な投稿のシステムを作る時、標準入力の結果を受け取る事ができると便利ですよね。
今回はその方法について。

実際のこころ

文字列"SOMETHING"をcurlでYOUR_DISTに送る場合、以下のようにします。

$ echo "SOMETHING" | curl YOUR_DIST -X POST -d @-

"@-"が標準入力を受け取るとこですね。

"@FILENAME"とすると、ファイルの中身を送信することもできます。

XWindow環境(i3など)で"Fatal server error: could not open default font 'fixed'"と出たら……フォントの入れ忘れかも

XWindow環境(i3など)で"Fatal server error: could not open default font 'fixed'"と出たら……フォントの入れ忘れかもしれません。

実際おtころ

環境を再構築していた時のこと……。

$ vncserver :1 -geometry 1280x800 -depth 24
Couldn't start Xtightvnc; trying default font path.
Please set correct fontPath in the vncserver script.
Couldn't start Xtightvnc process.

23/11/18 08:11:16 Xvnc version TightVNC-1.3.9
23/11/18 08:11:16 Copyright (C) 2000-2007 TightVNC Group
23/11/18 08:11:16 Copyright (C) 1999 AT&T Laboratories Cambridge
23/11/18 08:11:16 All Rights Reserved.
23/11/18 08:11:16 See http://www.tightvnc.com/ for information on TightVNC
23/11/18 08:11:16 Desktop name 'X' (linaro-alip:1)
23/11/18 08:11:16 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
23/11/18 08:11:16 Listening for VNC connections on TCP port 5901
Font directory '/usr/share/fonts/X11/misc/' not found - ignoring
Font directory '/usr/share/fonts/X11/Type1/' not found - ignoring
Font directory '/usr/share/fonts/X11/75dpi/' not found - ignoring
Font directory '/usr/share/fonts/X11/100dpi/' not found - ignoring

Fatal server error:
could not open default font 'fixed'
23/11/18 08:11:17 Xvnc version TightVNC-1.3.9
23/11/18 08:11:17 Copyright (C) 2000-2007 TightVNC Group
23/11/18 08:11:17 Copyright (C) 1999 AT&T Laboratories Cambridge
23/11/18 08:11:17 All Rights Reserved.
23/11/18 08:11:17 See http://www.tightvnc.com/ for information on TightVNC
23/11/18 08:11:17 Desktop name 'X' (linaro-alip:1)
23/11/18 08:11:17 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
23/11/18 08:11:17 Listening for VNC connections on TCP port 5901
Font directory '/usr/share/fonts/X11/misc/' not found - ignoring
Font directory '/usr/share/fonts/X11/Speedo/' not found - ignoring
Font directory '/usr/share/fonts/X11/Type1/' not found - ignoring
Font directory '/usr/share/fonts/X11/75dpi/' not found - ignoring
Font directory '/usr/share/fonts/X11/100dpi/' not found - ignoring

Fatal server error:
could not open default font 'fixed'

エラーをみると、どうもフォント周りのようなので

$ sudo apt install xfonts-base
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  xfonts-encodings xfonts-utils
The following NEW packages will be installed:
  xfonts-base xfonts-encodings xfonts-utils
0 upgraded, 3 newly installed, 0 to remove and 250 not upgraded.
Need to get 6557 kB of archives.
After this operation, 8380 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

#...

Setting up xfonts-utils (1:7.7+4) ...
Setting up xfonts-base (1:1.0.4+nmu1) ...

これであらためてやると……はい動きました。

$ vncserver :1 -geometry 1280x800 -depth 24

New 'X' desktop is linaro-alip:1

Starting applications specified in /home/linaro/.vnc/xstartup
Log file is /home/linaro/.vnc/linaro-alip:1.log

こういう事は構築に慣れた時ほど見落としがちです。
……なに、Docke? そんなハイカラなもん使えません(逆ギレ

scpコマンドでUNIX系システム間ファイル送信

scpコマンドをつかうと、UNIX系システム間ファイル送信できます。
たとえば、macOS上でセコセコ作っていたC++のコードをRasPiに転送したり……。

manの解説によると以下の通りなので……sshコマンドの仕組みを使ってるようです。

scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1).

実際のところ

接続先が"pi@192.168.0.xxx"だとして……

今いるディレクトリのmain.py

$ scp ./main.py pi@192.168.0.xxx:~/www

直下のwwwのディレクトリを再帰的に

$ scp  -rC ./www pi@192.168.0.xxx:~/www

参考もと

【読書メモ】9割が結果を出す! 小さな会社の脱零細マニュアル

9割が結果を出す! 小さな会社の脱零細マニュアル

9割が結果を出す! 小さな会社の脱零細マニュアル

同一LAN内のIP addressをしらべる

タイトルまんまで、同一のLAN内(同一サブネット内)につながっている機体のIPアドレスを調べる方法について。

実際のところ

$ echo 192.168.0.{1..254} | xargs -P256 -n1 ping -s1 -c1 -W1 | grep ttl | cut -d" " -f 4 | tr -d :
192.168.0.3
192.168.0.1
192.168.0.13
192.168.0.18
192.168.0.21
...
192.168.0.201
192.168.0.202
192.168.0.254
192.168.0.253

また、grepのトコを"ttl=64"とすると

$ echo 192.168.0.{1..254} | xargs -P256 -n1 ping -s1 -c1 -W1 | grep ttl=64 | cut -d" " -f 4 | tr -d :
192.168.0.3
192.168.0.21
...
192.168.0.202
192.168.0.201
192.168.0.253

この続きにxargsなどをくっつけると総当たり式にsshでログイン試行という地獄のようなこともできます……(小声