= iocsh上でシステムコマンド実行 = == build方法 == EPICS version 3.14.5 以降が必要。 例えばよく使う "example application" の場合には ioc_system.dbd ファイルを作成して中に {{{ registrar(iocshSystemCommand) }}} と記載し、Makefileで {{{ example_DBD += ioc_system.dbd }}} とすれば良いだけ。すると iocsh 上で help と打つと system コマンドが使えるようになっていることが分かる。 == 使用例と感想 == {{{ hepics> help Type 'help command_name' to get more information about a particular command. ...,. setIocLogDisable system taskwdShow tpn ...... epics> epics> system date 2017年 5月 23日 火曜日 09:50:46 JST epics> }}} バックグランドで実行したいときや、引数を与えたいときには(良い例ではないですが)例えば xclock だと {{{ epics> system "xclock &" }}} のようにクオートで括れば良い。 ただし、このままだと2重・3重にスクリプトが起動できるので実際の運転に使うにはちょっと....それくらいならば procServを使った方が色々な面で良いと思う(2重起動を防止とか、ログ出力とか、マシン起動時に実行するとかできるので) == 経緯 == [http://www.rri.kyoto-u.ac.jp/EPICS/program.html EPICS Collaboration Meeting 2017] においてNSLS2の発表スライド中でsystemコマンドを実行していることに気づいた。 以前から「おそらく出来るだろう」くらいには思っていたが使う機会もなく全く試すことはなかったが、あらためて application dev. guide をみるとちゃんと掲載されていた。 http://www.aps.anl.gov/epics/base/R3-16/1-docs/AppDevGuide/IOCShell.html#x19-73700018.2.5 {{{ Send command_string to the system command interpreter for execution. This command is present only if some application database definition file contains registrar(iocshSystemCommand) and if the system provides a suitable command interpreter (vxWorks does not). }}} ついでに、いつから実装されていたのかを確認したところ、3.14.5 のRelease Note に記載があった。 http://www.aps.anl.gov/epics/base/R3-14/5-docs/RELEASE_NOTES.html {{{ IOC shell system command The 'system' command has been added to the IOC shell. To enable this command, add registrar(iocshSystemCommand) to an application database description file. }}}