Perl – matoken's blog https://matoken.org/blog Is there no plan B? Mon, 28 Feb 2022 15:38:24 +0000 ja hourly 1 https://wordpress.org/?v=6.9.1 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg Perl – matoken's blog https://matoken.org/blog 32 32 moshが起動しなくなって困る https://matoken.org/blog/2022/02/28/mosh-does-not-start/ https://matoken.org/blog/2022/02/28/mosh-does-not-start/#respond Mon, 28 Feb 2022 14:33:57 +0000 http://matoken.org/blog/?p=3450

Debian sid amd64環境でmoshが動かなくなった.

$ mosh
IO.c: loadable library and perl binaries are mismatched (got handshake key 0xed00080, needed 0xeb00080)

mosh-clientは動くけど ~/.ssh/config を見てくれないので面倒

$ mosh-client
mosh-client (mosh 1.3.2) [build mosh 1.3.2]
Copyright 2012 Keith Winstein <mosh-devel@mit.edu>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Usage: mosh-client [-# 'ARGS'] IP PORT
       mosh-client -c

mosh は perl script

$ file /bin/mosh
/bin/mosh: Perl script text executable
$ grep -v ^# /bin/mosh | head


use 5.8.8;

use warnings;
use strict;
use Getopt::Long;
use IO::Socket;
use Text::ParseWords;
use Socket qw(IPPROTO_TCP);

mosh-client はelf

$ file /bin/mosh-client
/bin/mosh-client: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=9145424edb62c61b0081efeaa68ea20a25a73e5f, for GNU/Linux 3.2.0, stripped

sidだしPerlのアップデートもあったのでそのせいかなと思っていたけどしばらく経っても直らない.

cpanやcpanmも動かない.cpanは ~/perl5 を見ている.
最近Debian sidのPerlのバージョンが上がったのに ~/perl5 を更新していないので不整合となっていたよう.
一旦 ~/perl5 を退避して動作するように.
ディストリビューションアップデート時などにも嵌りそう.

$ cpanm --list
IO.c: loadable library and perl binaries are mismatched (got handshake key 0xed00080, needed 0xeb00080)
$ which cpan
/home/matoken/perl5/bin/cpan
$ which cpan
/home/matoken/perl5/bin/cpan
$ mosh
Usage: /usr/bin/mosh [options] [--] [user@]host [command...]
        --client=PATH        mosh client on local machine
                                (default: "mosh-client")
        --server=COMMAND     mosh server on remote machine
                                (default: "mosh-server")

        --predict=adaptive      local echo for slower links [default]
-a      --predict=always        use local echo even on fast links
-n      --predict=never         never use local echo
        --predict=experimental  aggressively echo even when incorrect

-4      --family=inet        use IPv4 only
-6      --family=inet6       use IPv6 only
        --family=auto        autodetect network type for single-family hosts only
        --family=all         try all network types
        --family=prefer-inet use all network types, but try IPv4 first [default]
        --family=prefer-inet6 use all network types, but try IPv6 first
-p PORT[:PORT2]
        --port=PORT[:PORT2]  server-side UDP port or range
                                (No effect on server-side SSH port)
        --bind-server={ssh|any|IP}  ask the server to reply from an IP address
                                       (default: "ssh")

        --ssh=COMMAND        ssh command to run when setting up session
                                (example: "ssh -p 2222")
                                (default: "ssh")

        --no-ssh-pty         do not allocate a pseudo tty on ssh connection

        --no-init            do not send terminal initialization string

        --local              run mosh-server locally without using ssh

        --experimental-remote-ip=(local|remote|proxy)  select the method for
                             discovering the remote IP address to use for mosh
                             (default: "proxy")

        --help               this message
        --version            version and copyright information

Please report bugs to mosh-devel@mit.edu.
Mosh home page: https://mosh.org

環境

$ dpkg-query -W mosh perl
mosh    1.3.2-2.1+b3
perl    5.34.0-3
$ lsb_release -dr
Description:    Debian GNU/Linux bookworm/sid
Release:        unstable
$ arch
x86_64
]]>
https://matoken.org/blog/2022/02/28/mosh-does-not-start/feed/ 0
Lingr の bot を作ってみた https://matoken.org/blog/2014/06/25/lingr_bot/ https://matoken.org/blog/2014/06/25/lingr_bot/#respond Tue, 24 Jun 2014 20:21:40 +0000 http://matoken.org/blog/?p=547

鹿児島らぐLingr room を作ってみたので,そこにML のSubject を流すbot を設置してみました.

こちらにページに作り方が載っています.bot用のAPI があるので楽々です.

bot 登録

以下のページでbot を登録します.

  • “Lingr” http://lingr.com/bot/create

    • Bot id : 任意
    • Callback URL : このURL にroom の内容が飛んできます.その内容から反応したりすることが出来ます.とりあえず最低限HTTP で200 を返すものを用意して指定.

メッセージ受信用のcgi を作成

ひとまず受け答えはしないつもりなのでHTTP 200 を返すだけのScript を用意.

投稿テスト

get だけで投稿できるので試しに投稿してみます,

以下のページで情報が入手できます.

“Lingr” http://lingr.com/developer

bot_verifier は載っていませんが,bot ID とSecret から求められます.
KagolugML_botxxxxxxxxxxxxxxxxxxxxxxxxxxx を結合した文字列をsha1 にかけます.

$ echo -n 'KagolugML_botxxxxxxxxxxxxxxxxxxxxxxxxxxx'|sha1sum 
b3c03556dca8dfffb8c509cb709817044c98ad87  -

この場合 b3c03556dca8dfffb8c509cb709817044c98ad87bot_verifier です.

  • 投稿先のroom : kagolug
  • bot ID : KagolugML_bot
  • bot_verifier : b3c03556dca8dfffb8c509cb709817044c98ad87

以下のようにアクセスしてみるとroom にメッセージが投稿されました,

w3m -dump ‘http://lingr.com/api/room/say?room=kagolug&bot=KagolugML_bot&text=はろーわーるど&bot_verifier=b3c03556dca8dfffb8c509cb709817044c98ad87

メールからLinger に投稿

鹿児島らぐのML だけを登録したメールアドレスを用意.そのアドレスの .forward に以下のSctipt を呼ぶように "|exec /home/mk/bin/ml2lingr.pl" のような感じで設定しておきます,後はメールが届くとこのScriptが呼ばれてRoom に投稿されます.


※bot_verifier はダミーです.

てことでirc のbot とか書くよりずっとお手軽に書けました.
今回は単に投稿するだけですが,cgi でroom のメッセージを解析して反応するとかするとbot らしくなりますね.

]]> https://matoken.org/blog/2014/06/25/lingr_bot/feed/ 0