× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Kevin,

I am going to digress further than you probably need for the sake of the
arhives.

are there any HowTo's to v8 on an iSeries, setting the correct paths and
all that?

When I log onto a customer's system I always run the following first to
learn where they're at (many installed the original versions of node,
0.12.x, 4.x, 6.x). In this case it is the version I desire.

$ node -v
v8.9.4

If it's not the version you desire you can learn which node binary is used,
including location, by running the following command:

$ which node | xargs ls -l
-rwxr-xr-x 1 qsys 0 52735018 Mar 5 23:45 /QOpenSys/pkgs/bin/node


If it's not the one you desire then you need to look at what I call the
"PASE library list", aka the PATH environment variable:

$ echo $PATH
/QOpenSys/pkgs/bin:/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin


When you enter a command (i.e. node -v) it will search the directories
specified in the PATH from left to right. On this particular system I
actually have Node.js v8.x and v6.x installed. Node.js v8.x is in
/QOpenSys/pkgs/bin and Node.js v6.x has a symbolic link in
/QOpenSys/usr/bin that points to /QOpenSys/QIBM/ProdData/OPS/Node6/bin.

In short, if you want to pick up Node.js v8.x you should put
/QOpenSys/pkgs/bin as the first entry in your PATH environment variable, as
shown below. Note how I append the existing $PATH so as to not lose the
existing paths.

export PATH=/QOpenSys/pkgs/bin:$PATH

Note the above is only for current sessions or sessions forked from the
current session. If you want that set as the default path when you log in
then you should do the following:

echo "export PATH=/QOpenSys/pkgs/bin:$PATH" >> ~/.profile

The above will append that export statement to your .profile file which is
looked at when you first log in. Note I am expecting you to be using bash
as your shell.

Hope that helps.


Aaron Bartell
IBM i hosting, starting at $157/month. litmis.com/spaces


On Thu, Mar 29, 2018 at 3:23 PM, Kevin Nunn <nunn.kevin@xxxxxxxxx> wrote:

Well, chop me down with a herring!

I left for a meeting, came back and isolated the sql code to simplify it
and see if I break it down and figure it out. I was going to show a
co-worker the SQL problem and boom, it worked, and I have no idea why! But
the CL part of it is still giving me the SQLDescribeParam() failed error.

Aaron, I know you are one of the Open Source gurus around here, are there
any HowTo's to v8 on an iSeries, setting the correct paths and all that?

It took me a few days to figure out I had to get all the PTFs for 5733OPS
to actually have all the actual software, and then it kept running Node
v0.12, not v6, but I knew it was installed. So I ended up changing the
symbolic links manually. I just found the documentation that tells you to
run a script to do that today. :P

Thanks,

Kev


On Thu, Mar 29, 2018 at 3:05 PM, Kevin Nunn <nunn.kevin@xxxxxxxxx> wrote:

Thanks for the reply Aaron

It is version 6, the default install of 5733OPS plus PTFs, although I did
install v8 rpm and then "yum erase"d it. V8 would not run, probably due
to
lib path issues and since I am new to all this, I decided it would be
best
to stick with the defaults. But possibly the install/erase of v8 broke
things?

Below is the code. It's a basic copy/paste of what I found on the link
listed in the first email. except for the db credentials, etc.

var http = require('http');
var fs = require('fs');
var url = require('url');
var db = require('/QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/
lib/db2a');
var xt = require('/QOpenSys/QIBM/ProdData/OPS/Node6/os400/
xstoolkit/lib/itoolkit');

var DBname = "*LOCAL";
var userId = "user";
var passwd = "pass";
var ip = "IPaddress";
var port = 8000;

var webserver = http.createServer((req,res) => {
var realPath = __dirname + url.parse(req.url).pathname;
fs.exists(realPath, (exists) => {
if(!exists){
var sql = url.parse(req.url, true).query.sql;
var cl = url.parse(req.url, true).query.cl;
if(sql && sql.length > 0) {
console.log("SQL statement : " + sql);
var dbconn = new db.dbconn();
dbconn.conn(DBname, userId, passwd); // Connect to the DB
var stmt = new db.dbstmt(dbconn);
stmt.exec(sql, (rs) => { // Query the statement
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(JSON.stringify(rs));
console.log(rs);
stmt.close();
dbconn.disconn();
dbconn.close();
});
}
if(cl && cl.length > 0) {
console.log("CL statement : " + cl);
var conn = new xt.iConn(DBname, userId, passwd);
conn.add(xt.iSh("system -i " + cl));
conn.run((rs) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(xt.xmlToJson(rs)[0].data);
});
}
} else {
var file = fs.createReadStream(realPath);
res.writeHead(200, {'Content-Type':'text/html'});
file.on('data', res.write.bind(res));
file.on('close', res.end.bind(res));
file.on('error', (err) => {
res.writeHead(500, {'Content-Type':'text/plain'});
res.end("500 Internal Server Error");
});
}
});
});
webserver.listen(port, ip);
console.log('Server running at http://' + ip + ':' + port);


On Thu, Mar 29, 2018 at 2:34 PM, Aaron Bartell <aaronbartell@xxxxxxxxx>
wrote:

What version of Node.js?

Can you post your code so we know exactly which example you're talking
about?

FWIW, if you're using Node.js v6.x then I'd upgrade to Node.js v8.x and
work through issues with that version. https://github.com/nodejs/
Release

Aaron Bartell
IBM i hosting, starting at $157/month. litmis.com/spaces


On Thu, Mar 29, 2018 at 2:27 PM, Kevin Nunn <nunn.kevin@xxxxxxxxx>
wrote:

I am researching db2i and itoolkit by starting with IBM's examples at
https://www.ibm.com/developerworks/ibmi/library/i-native-js-
app-ibmi-with-
nodejs/
at not having much luck.

The SQL part of the script is connecting to the DB2 server, but any
"Select
* From library/db" results in an empty brackets []. If I send query
"VALUES
current date", I do get [{"00001":"2018-03-29"}] back. If I put in bad
credentials, I do get auth errors, so it seems to be connecting to the
server.

The same queries work fine from STRSQL.

Also the CL part of the example just returns

Error: SQLSTATE=PAERR SQLCODE=-1 SQLDescribeParam() failed.
at Error (native)

I am new to nodejs, the plan was to find examples for the iSeries,
watch
them work, then see how the work and start from there.

Also wondering if my other issue might have some relation to this
problem
(see "Broken npm?" thread in OpenSource).

Thanks

Kev

--
*Kevin Nunn <https://about.me/kevinnunn>*
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.

--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.




--
*Kevin Nunn <https://about.me/kevinnunn>*




--
*Kevin Nunn <https://about.me/kevinnunn>*
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.