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

问题描述 投票:0回答:3

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

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

csession instancename
zn "area"
area>D ^%RI
Device:some/device/path
Next: It should take enter
linux shell unix aix intersystems-cache
3个回答
1
投票

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

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

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


0
投票

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

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 sectionthe terminal scripts section


0
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.