I have a NodeJs (14 & 18) service which list and read files from the local filesystem, on IBMi or AS/400...
I use:
await fsPromises.readdir(mydir)for to list all files of my directoryawait fsPromises.readFile(filename)for to read the content...
For filenames without accent, there is no problem... But, when there are some french accents, I have several problems:
readdir(mydir)return name_��.png instead of name_éè.png ... But I resolve this first problem with the encoding parameter, andreaddir(mydir, {encoding: 'binary'})return the good name !calling
await fsPromises.readFile('name_éè.png')orawait fsPromises.readFile('name_éè.png', {encoding: 'binary'})causes an access exception: name_��.png: ENOENT: no such file or directory
It seems that the "encoding" option only applies to the result, and not to the filename parameter. This problem does not seem to exist on a Windows machine, but seems specific to AS/400.
Context: Software version: tested with NodeJS v 14.21.3, and OS400 V7R3
Usually it is started via a CL which contains the command
CMD(QSH CMD(&CMD)) JOB(&JOB) JOBQ(QUSRNOMAX) CCSID(1147) SPLFACN(*DETACH)
where &CMD is the path of the SH script ( node app.js &)
and &JOB is the service's name...
I also tested it whithout the CCSID(1147) parameter, but I had the same problem... (finally, it doesn't mean anything because it's the system default...)
Any idea to resolve this ? Thanks
Generally speaking, QSH is a bad choice for running PASE programs.
Think of
QSHas a IBM native "Unix like" shell emulmation. The commands available are alias to actual *PGM objects.When dealing with PASE tools and open-source packages specifically, a real Unix/Linux shell is preferred. For interactive usage, SSH from your client PC is preferred. If you absolutely have no choice to use 5250, then
QP2TERMis a better choice thanQSH.For starting a batch job aka background service, the PASE shells
QP2SHELLandQP2SHELL2are possible options. Be sure to read and understand the notes for those commands.However, the absolute best way to handle open-source services on the IBM i is via the open-source Service Commander
Lastly, if non of the above helps, you may want to reach out to other IBM i open source communities.