Multi-line terminal commands
Let's say I have this simple script file try.script
write 1 write 0
I can execute it in a terminal (csession) by calling:
csession cache < try.script
And I get the following output:
%SYS> 1 %SYS> 0
However I want to use a try catch block in my script:
try { write 1/0 catch {} halt
But as script is executed line by line, it's interpreted like this:
%SYS> TRY { ^ <SYNTAX> %SYS> WRITE 1/0 ^ <DIVIDE> %SYS> CATCH {} ^ <SYNTAX> %SYS>
I know that I can write it all in 1 line, but I'd rather not do that. Is there a way to feed multiline statement into Cache?
Why not put your code in a mac routine and call the routine from your script file. Might be easier.
It's executed during container build, so to load something I need a script.
Make your script create an INT routine and run it. Example try.script below. Your lines of code either begin with the TAB character or with a label followed by TAB.
Here's an output I get:
Looks like it's still line-by-line execution.
It worked for me (2017.2.2 on Windows):
Maybe your indented script lines (the ones to insert into the routine) aren't starting with $C(9)
Thank you, missed the TABs.
Contents of a Script File:
Script files are line oriented; there is no line-continuation convention. Each line is separate from any other. Lines beginning with a semicolon are considered comments. You can use blank lines liberally to improve readability. Normally, invalid lines are ignored. Script commands may be preceded by spaces and/or tabs.
This option
https://community.intersystems.com/post/terminal-multi-line-option
or the extended one with editor support
https://community.intersystems.com/post/terminal-multi-line-command-editor
could be useful.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue