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