- Log in to post comments
User bio
404 bio not found
Member since Jun 15
Posts:
Rob has not published any posts yet.
Replies:
Howdy, Robert!
I'm another Rob(ert) and I've been a longtime reader (and fan) of your posts here in the developer community. Thank you for elucidating this use case of XECUTE, I have not considered using this command in a here-document before and I admire your approach! I would also like to share some of the workarounds that I've used in the past to approach similar problems:
Escape newline characters in your here-document:
var="InterSystems"
irissession MYIRIS -U%SYS<<EOF
FOR i=1:1:10 {\
W i,!\
}
W !,"Howdy, $var!",!
H
EOFSplit your string and join it on a space (easiest to use in perl and python IMHO):
import subprocess
# Let's interpolate a variable
var = "InterSystems"
# Build iris_cmd
iris_cmd = f"""
FOR i=1:1:10 {{
W i,!
}}
W !,"Howdy, {var}!",!
H
"""
# write one-big line
iris_cmd = ' '.join(iris_cmd.split()) +"\n"
# Run commands in an irissession
proc = subprocess.run(
['irissession', 'IRISHEALTH', '-U', '%SYS'],
input=iris_cmd,
check=True,
capture_output=True,
text=True
)
for line in proc.stdout.splitlines():
print(line)
Have your here-document write a routine and execute it:
cls="Config.Databases"
mthd="ListFunc"
irissession MYIRIS -U%SYS<<EOF
ZI "zExecute(cls,mthd);"
ZI " S rset=\$CLASSMETHOD(cls,mthd)"
ZI " WHILE (rset.%Next()) {"
ZI " W rset.Name,?20,rset.Directory,!"
ZI " }"
D zExecute("$cls","$mthd")
H- Log in to post comments
Certifications & Credly badges:
Rob has no Certifications & Credly badges yet.
Followers:
Rob has no followers yet.
Following:
Rob has not followed anybody yet.
I think if you embed the "q" in a here-document or pipe your commands into cache that this should work