Administrator interface updates via command line

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Namtar78
Participant
Posts: 3
Joined: Mon Apr 22, 2019 8:18 pm

Administrator interface updates via command line

Post by Namtar78 »

Hi,

i know this post is old but i can't find any other thread about this subject.

I'm a beginer in DataStage, and i try to build a script in SHELL for the exploitation of DataStage.
But i have a issue with the environment variables file. (.env)

I don't know the command line to import this file.
I saw the "dsadmin.sh" and the options that i can use like "-envadd" or "-envset", but it doesn't seem to be what i need.

So here my question :
Do you know how to import the environment file (.env) in UNIX command line please ? :cry:

PS : Sorry for my bad english :oops:
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

Your English is quite okay.

We use a command line via a scheduler job (Control-M), and the script we use is dependent on a project ssi file that contains the environment variables and their values. To add our update, we modify the ssi file and run the script.

Sample command lines:

Code: Select all

${DSHOME}/bin/dsadmin ${G_DS_ADMIN_CLI_ARGS} -envadd ${VARNAME} -type STRING -prompt "Env var ${VARNAME}" ${G_DS_PROJ_NAME}

${DSHOME}/bin/dsadmin ${G_DS_ADMIN_CLI_ARGS} -envset ${VARNAME} -value "${VARVALUE}" ${G_DS_PROJ_NAME}
The script sets the variables you see, and you'll need a skilled script writer to translate that to your needs. The variables which begin with "G_DS" are the ones included in the ssi file.

The .env file is only for manual user use via the Administrator interface. You could write a script to use it, but it would be less complicated to build it yourself.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Import environment file in a script

Post by chulett »

Namtar78 wrote:i can't find any other thread about this subject.
That's when you start a new post... and link back to the other one if it's related. I've done that for you but they're not really the same issue. But no worries, we're here now.

We would typically just "source" the environment file in the script to bring all of the values into the session / process space the script is running in. Depending on your shell there's an actual source command or the "dot" (a period) is a synonym for it. Depending on the position of that file to the current working directory, you could:

Code: Select all

. .env

-or-

. ./.env

-or-

. /full/pathname/.env

-or-

replace the first "." in any line above with "source"
This will bring whatever it is setting into the session's environment. Unless I'm missing the point of all this, of course. :(

Conversations online for this can be found by searching for dot space dot slash - literally those four words.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Namtar78
Participant
Posts: 3
Joined: Mon Apr 22, 2019 8:18 pm

Re: Import environment file in a script

Post by Namtar78 »

Thank you both for your answers :wink:

FranklinE: If i understand correctly, you compare the variables you have in your project with the file that you received to find the new variables to add or to update ?

chulett: I'm quite interest with that solution (more simple :P ) but how do you set your project ?

When i have to uprading or creating a project, my developers send me a package with a environment variables file that i have to add in the project and him only.
So if i just have to "source" the file, great :D ... but how can i source him in my project :?

With the Administrator interface, i can import the file with no worries, he do the compare himself and add or update the variables.

My point is to to do the same thing that the Administrator interface, but in command line. I can't beleive that the only solution is to compare manualy and then add the variables one by one.
or maybe i expect to much... i'm a lazy guy, that why :P
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Thank you for clarifying your requirements. My answer was meant to be very generic educational information - shell scripts and environment variables - with nothing related to use of the Administrator interface or projects or anything else 'DataStage exploitation' specific. Thought it might come in handy for you... someday. :wink:

Franklin has the specifics you need for this task. I should go back and fix the subject I decided to use for your post. Also, in case it matters, can you confirm what version of the product you are on? I11.x? had to guess.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Namtar78
Participant
Posts: 3
Joined: Mon Apr 22, 2019 8:18 pm

Post by Namtar78 »

Chulett : I use the 11.5 version

I have a question :
Instead of doing some compare between the variables in my file and in my project, would not it be easier to make a loop that would add all the variables in my file to the project ?
It would be like an "overwrite" no ?
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

The code I posted is out of the context of the script we use. Unfortunately, I can't post the rest because it's proprietary and not my place to share it.

I've not looked at the IBM documentation of the admin functions in too long, about 1,000 cyber years ago when we were using 7.x. If one of the functions is to read the current variables and their values first, you could use that, but my experience with importing via Administrator is that the wizard will update if the variable is found and the value is different, and will skip if the value has not changed.

Using a ssi file or similar sourced file as your baseline for the variables gives you basic version control. Use it for the initial import, and use it to make changes. If you have effective version control on the file, you should be confident that your environment variables are accurate.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
Post Reply