Thanks Yahagi. So, it seems we have to find another way to pass the Arabic text string as argument. We are testing using python data base package to fetch the Arabic text string argument.
Original Message:
Sent: Mon February 12, 2024 08:13 PM
From: 英幸 矢作
Subject: $PATH on a CLP?
It seems like you are talking about argument issue, not path.
I think you can specify only ASCII characters when call pase shell from CL program.
In the Note at "How to Call PASE Commands/Scripts from a Command Line, CL Program, or in a Submitted Job",
IBM states that DBCS characters cannot be used, but may also apply to Arabic.
There are several ways to invoke python from CL.
If you want to path non-ASCII argument to python, I would use CGI or other method (use database, parameter file, etc.)
Yahagi@Japan
------------------------------
英幸 矢作
Original Message:
Sent: Fri February 09, 2024 01:04 AM
From: Vinit Kumar
Subject: $PATH on a CLP?
First of all, a big thank you for this insightful discussion,
We are facing the exact same situation with CCSID conversion for Arabic text string but through PASE. Through PASE environment on IBM i, we are calling py3.9 code, with Arabic text string as argument. The code creates a pdf file with qrcode and Arabic text inserted in one of the fields in pdf file. The file is exported from navigator to windows PC. The file shows Arabic text as gibberish (little boxes). However, the same stuff and code works completely fine through ssh session to IBMi. From both ways, the CCSID of the generated PDF file is 819 only. We tried to pass the Arabic text string in utf-8 format with CCSID 1208, but still the same issue.
After going through the post, we will try to provide the PATH variable explicitly, while calling the py3.9 from PASE environment. Hope this helps and resolves our issue.
Regards,
Vinit Kumar
------------------------------
Vinit Kumar
Original Message:
Sent: Thu January 26, 2023 10:41 AM
From: Vincent Greene
Subject: $PATH on a CLP?
Interesting. I never saw that page. Thank you for bringing that to my attention.
If you are executing the command via ssh, you are entirely within the PASE environment, so having the PASE commands at the front of the PATH would probably be preferable. I should note that your path in that environment is determined via a different process that involves the SSHD configuration, and the specific shell that is executed, so sourcing the .profile file in your call is probably not desirable. That means no changes are likely to be necessary for your ssh calls.
If you are executing from QSH, I would expect that the preference would be to run the QShell version of commands, but it probably depends on whether those commands are going to be executed as subprocess from the PASE environment (e.g. a system command inside the Python code), or as a pipeline from the QShell environment (e.g. piping the Python output via grep).
Bottom line is I am less confident in that part of my original answer now. I will try to engage the IBM OSS team to find a more definitive answer and report back. Until then, if you get ccsid conversion type issues/unreadable data, etc. try switching the PATH to see if that resolves it.
If you don't have any conversion problems, there is probably no need to change the path no matter how you currently have it set.
------------------------------
Vincent Greene
IT Consultant
Technology Services
IBM
Vincent.Greene@ibm.com
The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Original Message:
Sent: Thu January 26, 2023 02:01 AM
From: 英幸 矢作
Subject: $PATH on a CLP?
Let me check on the PATH settings.
> One more thing. In my examples, you may have noticed I put the added directory at the end of the path, rather than the beginning.
"IBM i OSS Docs" says "The PATH should contain, at minimum, /QOpenSys/pkgs/bin, very preferrably before the "standard" paths."
Would it be best practice to have $PATH at the beginning when calling the PASE program from CL via qshell and $PATH at the end when calling from ssh?
------------------------------
Hideyuki Yahagi @ Japan
Original Message:
Sent: Wed January 25, 2023 11:01 AM
From: Vincent Greene
Subject: $PATH on a CLP?
I can shed a bit more light on this issue.
First of all, for many reasons, calling your Python script using QSH is the right thing to do. There are other options (QP2SHELL, QP2SHELL2 and QP2TERM), but they are more specialized and generally more difficult to use. Even though Python is a PASE program, QShell is the environment that is most likely to get all of your I/O where it belongs and properly converted to the correct ccsid, even when using a PASE program.
The difference you get in the environment is based on the QShell handling of the .profile or /etc/profile file where you most likely define your environment variables with something like:
PATH=$PATH:/QOpenSys/pkgs/bin
QSH only sources this file if you are running an interactive shell. By definition, if you specify a command, it is not an interactive shell, so no .profile file processing.
Most Unix shells have alternative files that will run for both interactive and non-interactive shells, but QSH does not.
The simple solution is just to force the .profile (or any file of your choice) to get sourced using the syntax:
QSH CMD('. $HOME/.profile;python3.9 myscriptname.py')
You may have noticed that there is an extra period at the beginning that looks out of place. That tells the Unix shell to SOURCE the file rather than EXECUTE the file. The difference is that sourcing a file just means running the commands in the current job level and context. That means the change to the environment variable occurs in the current process, not a sub-process that would immediately go away taking the newly set environment variable with it.
The $HOME gets expanded by the shell to the current HOME directory of the user, and the semicolon just separates multiple commands to be processed by the shell.
I very much prefer this method to the ADDDENVVAR in the CL program, primarily because it allows the Unix environment to be managed by the Unix environment, and is much easier to include the default PATH without hardcoding it in a CLP.
An alternative is:
QSH CMD('PATH=$PATH:/QOpenSys/pkgs/bin python3.9 myscriptname.py')
That just explicitly sets the path in the command. It is better than the ADDENVVAR approach, but hardcodes a value that, in my opinion, is better softcoded in the environment where it will be run.
One more thing. In my examples, you may have noticed I put the added directory at the end of the path, rather than the beginning. That is because there is some overlap in the QSH and PASE environment binaries. If there are two versions of the binary commands, you typically want the QShell version rather than the PASE version when you are running in the PASE environment.
------------------------------
Vincent Greene
IT Consultant
Technology Services
IBM
Vincent.Greene@ibm.com
The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Original Message:
Sent: Tue January 24, 2023 07:05 AM
From: Paulo Silva
Subject: $PATH on a CLP?
Dear Satid,
Thanks a lot for your help.
I have my user $PATH defined correctly and I was expecting that to be enough to run QSH commands.
From what I see that's not the case and it is still mandatory to define an environment variable on the CLP as suggested by Scott Klement.
That's what I did.
Thanks again Satid!
BR,
Paulo
------------------------------
Paulo Silva
Original Message:
Sent: Mon January 23, 2023 10:20 PM
From: Satid Singkorapoom
Subject: $PATH on a CLP?
Dear Paulo
I guess you need to explicitly set your PATH environment variable and you can do this in more than one way as described here : https://ibmi-oss-docs.readthedocs.io/en/latest/troubleshooting/SETTING_PATH.html
There are some tips on using Python in IBM i here : https://ibmi-oss-docs.readthedocs.io/en/latest/python/README.html The URL above is the first hot link of this Python Usage Note page.
Scott Klement also indicates this may be done from CL. So, please try to identify whichever suits your case.
------------------------------
Right action is better than knowledge; but in order to do what is right, we must know what is right.
-- Charlemagne
Satid Singkorapoom
Original Message:
Sent: Mon January 23, 2023 09:40 AM
From: Paulo Silva
Subject: $PATH on a CLP?
Hi,
I'm running a python scrip from a CLP with QSH with the following command: /QOpenSys/pkgs/bin/python3.9 mypythonscript.py and everything is working perfectly.
However when I do: python3.9 mypythonscript.py I get the message: qsh: 001-0019 Error found searching for command python3.9. No such path or directory.
I'm using the my own user profile.
This is what I see in the QSH shell:
echo $PATH
/QOpenSys/pkgs/bin:/usr/bin:.:/QOpenSys/usr/bin
With the same user btw running call QP2TERM, I get something different:
echo $PATH
/QOpenSys/pkgs/bin:/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
Am I doing anything wrong?
Thanks in advance,
Paulo
------------------------------
Paulo Silva
------------------------------