commandLineCall Not Signed In error

Use this board to ask questions or have discussions with other Profound.js users.
adriano.ascione
New User
Posts: 2
Joined: Thu Dec 12, 2019 9:46 am
First Name: Adriano
Last Name: Ascione
Company Name: iVolution
Contact:

commandLineCall Not Signed In error

Post by adriano.ascione »

Hello everybody,
I have a Profound.js instance installed on an IBMi server. Inside its node_modules, I have an application. What I'm trying to do, is to create a shell script that asks some informations to the user and then connects to an IBMi server and querys its database.
To do so, I am trying to take advantage of the features of Profound.js.
Cleaning the code to the basic operations, what I am doing is this:

Node.js code

Code: Select all

// Load Profound.js
var profoundjs = require('profoundjs');

const param = 'test';

// Call module
profoundjs.commandLineCall('iframework/pjsFunctions/test_i18n', param);
Profound.js module (located inside the modules directory of my Profound.js instance)

Code: Select all

function testQuery () {
  const translations = pjs.query('select * from profoundui.puitransp');
}
module.exports.run = testQuery;
What I get as a result is the following exception:

Code: Select all

/pjs-instances/iframework/node_modules/profoundjs/api/fiber.jse:134
          throw error;
          ^

Profound.js Error: Not signed in.
See https://docs.profoundlogic.com/docs/display/PUI/Not+signed+in
    at Object.profound.utils.connectorMessage (/pjs-instances/iframework/node_modules/profoundjs/utils/connectorMessage.jse:129:11)
    at Object.profound.callProcedure (/pjs-instances/iframework/node_modules/profoundjs/api/callProcedure.jse:78:30)
    at Object.db.connect (/pjs-instances/iframework/node_modules/profoundjs/db/drivers/IBMi/sql-driver.jse:185:40)
    at Object.profound.connect (/pjs-instances/iframework/node_modules/profoundjs/api/connect.jse:5:15)
    at Object.profound.utils.getConnection (/pjs-instances/iframework/node_modules/profoundjs/utils/getConnection.jse:23:16)
    at Object.profound.prepare (/pjs-instances/iframework/node_modules/profoundjs/db/sql-driver.jse:789:30)
    at Object.db.query (/pjs-instances/iframework/node_modules/profoundjs/db/drivers/IBMi/sql-driver.jse:105:23)
    at Object.profound.query (/pjs-instances/iframework/node_modules/profoundjs/api/query.jse:4:13)
    at Object.pjs.(anonymous function) [as query] (/pjs-instances/iframework/node_modules/profoundjs/api/pjs.jse:21:30)
    at Object.testQuery (/pjs-instances/iframework/modules/iframework/pjsFunctions/test_i18n.js:3:28)
My Profound.js instance is active as a batch process on the IBMi server.
Thank you in advance.
Best regards.
Adriano
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: commandLineCall Not Signed In error

Post by Scott Klement »

I'm not completely sure that I understand the question?

The commandLineCall() API is for calling a Profound.js module outside of the Profound.js server. This is explained in the docs, here: https://docs.profoundlogic.com/x/J4AOAg

I find the docs a bit misleading. They explain that we have a call.js script -- but then make it sound like this is needed to use the commandLineCall() function. In actuality, the call.js performs the commandLineCall, so you don't need to do both, just one or the other.

So if you have a Profound.js module named "testQuery.js" that's located inside "modules/myDir" you could invoke it from a shell script with:

Code: Select all

node call myDir/testQuery "parm1" "parm2"
Replace "parm1" and "parm2" with the parameters you want to pass to it, of course.

Since that script is not running in a Rich Display or Genie session (its running in a shell job) it will not have a connection to the database. That is likely why you're getting the "Not signed in" error. From looking at the code, I see there's an option of -login that you can provide to prompt you for the userid/password to log in. so I can do this:

Code: Select all

node call myDir/testQuery -login "parm1" "parm2"
When I do that, it asks me for the login info interactively in the shell, then it works successfully.

I also discovered from looking within the code that you can use the PJS_USER and PJS_PASSWORD environment variables to suppress it from interactively asking you for the login info. So you can do this:

Code: Select all

export PJS_USER=your-userid
export PJS_PASSWORD=your-password
node call myDir/testQuery -login "parm1" "parm2"
This worked okay for me.

Does that help you? If not, please explain the problem.
adriano.ascione
New User
Posts: 2
Joined: Thu Dec 12, 2019 9:46 am
First Name: Adriano
Last Name: Ascione
Company Name: iVolution
Contact:

Re: commandLineCall Not Signed In error

Post by adriano.ascione »

Hello Scott,
yes it helped. I solved the problem.
Thank you.
Best regards
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests