An Attempt to deploy a project using a shell script

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

An Attempt to deploy a project using a shell script

Post by rameshrr3 »

I have made a vague attempt at creating a shell script to deploy a new project , along with its 'user-defined' environment variables and jobs. Is ther any better way of doing it? Apart from capturing status codes of commands and validating input arguments? This is a 'forecasted' requirement from my client.


The file containing environment variable definitions ${4} is supposed to be created from the output of

Code: Select all

'dsadmin -listenv <projectName>' | grep "UD var prefix String" 
command

The Code for the 'deployment script' follows

Code: Select all

#!/usr/bin/ksh
# DSDeployProject.sh ( Rudimentary Script to deploy a new project)
# Assumes an already exported DSX file placed in an unix folder
# Assumes a Environment variable file 
# with records in NAME=VALUE pairs
# For simplicity all env variables are asusmed to be of string type
# Prompt Text is a default value , to be filled up by admin later
# For Simplicity , i assume user gives valid argument values!
#$1 is Name of new Project To be created
#$2 is the path of the Project Directory
#$3 is the dsx file to be imported( abosolute path)
#$4 is the ENV file for environment variable details
#(Can be filled with output of `dsadmin -listenv SourceProject > $4` command
# SYNTAX ./DSDeployProject.sh <ProjectName> <Project Directory Path> <DSX FilePath and Name> <ENV File name with "NAME=VALUE" records>

dsadmin -createproject $1 -location $2
dsjob -import $1 $3 -OVERWRITE

var_linecount=`cat $4 | wc -l`
echo $var_linecount

_i=1

echo 
while true
do
   echo $_i
   var_Name=`awk 'NR=='${_i}'' $4 |awk -F= '{ print $1 }'`
   var_Value=`awk 'NR=='${_i}'' $4 |awk -F= '{ print $2 }'`
   echo "Creating ENV Variable" $var_Name "=" $var_Value
   dsadmin -envadd $var_Name -type STRING -prompt "Enter Prompt Text" -value "$var_Value" $1 
let _i='_i+1'

if test $_i -gt $var_linecount
then
 echo "Loop Ended"
 exit 0
fi
done
How can i work around the limitations of the dsadmin -listenv command? Is there some better way of doing a deployment script?
Last edited by rameshrr3 on Thu Jun 14, 2007 6:23 am, edited 1 time in total.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What do you believe the "limitations of the dsadmin -listenv command" to be?

Does the script work in its present form?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

The dsadmin -listenv command does not give me the environment variable prompt string and type
( Encrypted/String) . It gives me only a list of
NAME=VALUE pairs

As far as testing goes:
I have been able to test so far much of the entire script( creating environment variables from and env file, importing a dsx file etc into an already created project) except for the project creation part, for which i do not have sufficient privileges.

Of course the dsenv is sourced in the admin user's profile file.So I dont have to source it again in the script.


The script will eventually be run by a user with admin privelege. I will be adding the exception handling and some basic argument validation clauses too.



Thanks
Ramesh
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You could always read and parse the environment variable definitions (maybe only the ones from -listenv) from the DSParams file.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

All variables that will be of encrypted type will be passwords. All such variable names will have _PWD in their names, hence i probably will scan the output of the dsadmin -listenv for those user variables that end with _PWD. For Prompt string, will use the environment variable name itself for now.

Thanks
Ramesh
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm curious about this 'forecasted requirement' from your client. What exactly is this all for? How often does one need to 'deploy' a project? I know some folks have many projects, sometimes way too many in my opinion, but hey - different strokes. The need for new projects is pretty rare around here.

As noted, just mostly curious. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea: A company like Peoplesoft would have exactly such a requirement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

When you have a client that is 'command line happy', where a script based solution, however rarely used, is considered the best, probably because it gives them a chance to show their geek ability with 'install' scripts. I Spent almost a day getting those single quotes right.:x .

On the flip side , and much to the disappointment of the 'client', there is not a straightforward & convinient way of exporting a project from unix command line.(At least in v 7.51A)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

To quote the Sergeant-Major from "It Ain't 'alf Hot Mum":
Sergeant-Major Tudor Bryn 'SHUT UP!' Williams wrote:Oh dear. How sad. Never mind.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply