如何从shell脚本在Intersystem缓存上执行某些命令?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何从shell脚本在Intersystem缓存上执行某些命令?相关的知识,希望对你有一定的参考价值。

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

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

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

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

echo -e "username
password
W "Hello world"
H
" | csession instance

请注意,您手动运行的每个命令都在那里,并以“ n”分隔,这是表示“Enter”键的字符。

另一答案

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

echo: off
wait for:Username
send: SYS<CR>
wait for:Password
send: XXX<CR>
echo: on

logfile: SomepathmyFile.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 sectionthe terminal scripts section

另一答案

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

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

myScript.scr

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

因此,在UNIX的情况下将它传递给缓存终端是使用csession与linux PIPE(|)运算符

cat myScript.scr | csession {instance_name}

Eg.

cat myScript.scr | csession CACHE

output

     a
     b
     c

Note:

• 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

以上是关于如何从shell脚本在Intersystem缓存上执行某些命令?的主要内容,如果未能解决你的问题,请参考以下文章