【问题标题】:How can I perform some commands on Intersystem cache from shellscript?如何从 shellscript 对系统间缓存执行一些命令?
【发布时间】:2013-05-23 13:17:27
【问题描述】:

我想从 shell 脚本对系统间缓存执行一些命令。我知道的一种解决方案是通过制作配置文件,但问题是我不知道如何通过 shell 脚本使用配置文件。有没有其他解决方案...

例如,我必须在缓存上运行的是

csession instancename
zn "area"
area>D ^%RI
Device:some/device/path
Next: It should take enter

【问题讨论】:

    标签: linux shell unix aix intersystems-cache


    【解决方案1】:

    这可以通过 Linux shell 完成,只需记录您需要执行的命令,然后将它们放入脚本中。这是一个登录 Cache 并编写“Hello world”的示例——请注意,这也假设您需要进行身份验证。

    echo -e "username\npassword\nW \"Hello world\"\nH\n" | csession instance
    

    请注意,您将手动运行的每个命令都在其中并用“\n”分隔,这是代表“Enter”键的字符。

    【讨论】:

      【解决方案2】:

      可以(对于某些操作系统)以批处理模式运行缓存终端。例如:

      echo: off
      wait for:Username
      send: SYS<CR>
      wait for:Password
      send: XXX<CR>
      echo: on
      
      logfile: Somepath\myFile.log
      
      send: ZN "AREA"
      wait for:AREA>
      
      send: D ^%RI
      wait for:Device:
      send: some/device/path
      wait for:Next:
      send: <CR>
      

      这记录在the Intersystems cache terminal documentation,尤其是the using terminal in batch mode section 和the terminal scripts section。

      【讨论】:

      • 我还是没明白。我是 shellscripting 和缓存的新手
      • 您阅读过任何文档吗?你尝试了什么?你没有得到什么?
      【解决方案3】:

      这是一个非常古老的问题 .. 因为我遇到了同样的事情,所以通过一些研发,我找到了解决这个问题的方法。这是非常酷和简单的。

      假设我有这个文件(可以是任何扩展名,每个命令在单独的行中)

      myScript.scr

           zn "%SYS"
           for e="a","b","c" { w e,! }
      

      所以在 UNIX 的情况下将其传递到缓存终端是使用带有 linux PIPE (|) 运算符的csession

      cat myScript.scr | csession {instance_name}

      例如

      cat myScript.scr | csession CACHE
      

      输出

           a
           b
           c
      

      注意:

      • Don't separate a command in multiple lines else `csession` will through <SYNTAX> error. (See how I wrote the *for* loop)
      • Extra knowledge - Intersystem Ensemble supports *Cache Terminal Batch Mode* in Windows case... While in linux there is no cterm to take the scripts.. 
      • But linux gives you a work around to do this ;).
      

      希望对大家有帮助!!欢呼:D

      【讨论】:

        猜你喜欢
        • 2011-10-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多