Question
· Oct 25, 2021

Running Python script from terminal vs studio

I have created on class method which execute below command

From terminal : _System account works fine where code=0

From Studio : _System account give syntax error where code=1

set code = $zf(-1,"python C:\keys\GetToken.py")

w !, code

Product version: IRIS 2020.1
$ZV: IRIS for Windows (x86-64) 2020.1 (Build 215U) Mon Mar 30 2020 20:14:33 EDT
Discussion (20)3
Log in or sign up to continue

Hi @Vic Sun , @Akshay Pandey :
Just to complete this discussion.

From Terminal I could run Py also from a JOB, and over CPIPE without problems.
From Studio Output all this FAILS.
Which makes clear that the process behind Studio is far away from being a normal
IRIS/Caché process and just good for editing and compiling.  FullStop.

I would even assume that running COS commands was not planned but rather an accident that happened 20 yerars ago.

 

Hi Akshay,

Robert is correct.

$ZF(-1,{os command}) is used to call commands from the underlying operating system.

The shell that you execute won't know where to find the python executable.

We can see this by trying to print the Windows PATH environment variable (below) as you would normally be able to do in a Windows CMD shell:

As we can see above the CMD shell can see the environment variable %PATH% but if we do the same echo %PATH% in terminal we see nothing.  

Cheers,
Patrick

I spent quite a while on the subject of python. Also the asynchronous $ZF(-2) + error log

write $zf(-2,"C:\Users\cemper\AppData\Local\Microsoft\WindowsApps\pythonw3.9.exe <c:\temp\in.py 1>c:\temp\5out.txt 2>c:\temp\5er.txt")

And the error from WINDOWS was always: the program can not be executed
A further reason to use
Embedded Python!

in.pyw is simply

print("success")
exit()