Unix env variables

Archive of postings to DataStageUsers@Oliver.com. This forum intended only as a reference and cannot be posted to.

Moderators: chulett, rschirm

Locked
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Unix env variables

Post by admin »

Is it possible to access Unix environment variables from within the DS Job Control script ?


regards,
Peter Oates
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Yes. For example to set the FRED environment variable to FLINTSTONE:

PERFORM "ENV SET FRED=FLINTSTONE"

To clear the environment variable:

PERFORM "ENV CLEAR FRED"


-----Original Message-----
From: Peter Oates [mailto:Peter.Oates@macquarie.com]
Sent: Tuesday, 23 October 2001 13:19
To: datastage-users@oliver.com
Subject: Unix env variables


Is it possible to access Unix environment variables from within the DS Job Control script ?


regards,
Peter Oates
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

PERFORM is documented in the BASIC manual.
ENV is a UniVerse command; get to a UniVerse prompt (perhaps in the Administrator client) and type HELP ENVIRONMENT, or get the User Reference manual from the web. Unfortunately, the only display at this level displays all variables.

However, by using the CAPTURING clause of EXECUTE, you can do what youre after.

EXECUTE SH -c "echo $HOME" CAPTURING EnvHOME
Call DSSetParam(hJob, "MyHomeDir", EnvHOME)

-----Original Message-----
From: Peter Oates [mailto:Peter.Oates@macquarie.com]
Sent: Tuesday, 23 October 2001 13:36
To: ray.wurlod@Informix.Com
Subject: RE: Unix env variables


Ray,

Where is this documented ? I cant seem to find this in the on-line doco.
More specifically, how do I set a DS variable to the value of a UNIX env variable ?

i.e. MyHomeDir = $home

thanks,
Peter
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Thanks for that Ray...it seems to work.
Im having problems with the DSSetParam in that it returns -4 - not happy with the value being set - even though the Parameter is type String.

-----Original Message-----
From: Ray Wurlod [mailto:ray.wurlod@Informix.Com]
Sent: Tuesday, 23 October 2001 2:53 PM
To: Peter Oates
Cc: datastage-users@oliver.com
Subject: RE: Unix env variables


PERFORM is documented in the BASIC manual.
ENV is a UniVerse command; get to a UniVerse prompt (perhaps in the Administrator client) and type HELP ENVIRONMENT, or get the User Reference manual from the web. Unfortunately, the only display at this level displays all variables.

However, by using the CAPTURING clause of EXECUTE, you can do what youre after.

EXECUTE SH -c "echo $HOME" CAPTURING EnvHOME
Call DSSetParam(hJob, "MyHomeDir", EnvHOME)

-----Original Message-----
From: Peter Oates [mailto:Peter.Oates@macquarie.com]
Sent: Tuesday, 23 October 2001 13:36
To: ray.wurlod@Informix.Com
Subject: RE: Unix env variables


Ray,

Where is this documented ? I cant seem to find this in the on-line doco.
More specifically, how do I set a DS variable to the value of a UNIX env variable ?

i.e. MyHomeDir = $home

thanks,
Peter
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

It may be that there is a line feed on the end of the captured output. This will have been translated to a "field mark" by CAPTURING. (I forgot about this gotcha.)
Try:
EXECUTE SH -c "echo $HOME" CAPTURING EnvHOME
Call DSSetParam(hJob, "MyHomeDir", Trim(Convert(@FM,"",EnvHOME)))


-----Original Message-----
From: Peter Oates [mailto:Peter.Oates@macquarie.com]
Sent: Wednesday, 24 October 2001 10:14
To: datastage-users@oliver.com
Subject: RE: Unix env variables


Thanks for that Ray...it seems to work.
Im having problems with the DSSetParam in that it returns -4 - not happy with the value being set - even though the Parameter is type String.
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Fixed.....Works a dream !

-----Original Message-----
From: Ray Wurlod [mailto:ray.wurlod@Informix.Com]
Sent: Wednesday, 24 October 2001 10:29 AM
To: datastage-users@oliver.com
Subject: RE: Unix env variables


It may be that there is a line feed on the end of the captured output. This will have been translated to a "field mark" by CAPTURING. (I forgot about this gotcha.)
Try:
EXECUTE SH -c "echo $HOME" CAPTURING EnvHOME
Call DSSetParam(hJob, "MyHomeDir", Trim(Convert(@FM,"",EnvHOME)))


-----Original Message-----
From: Peter Oates [mailto:Peter.Oates@macquarie.com]
Sent: Wednesday, 24 October 2001 10:14
To: datastage-users@oliver.com
Subject: RE: Unix env variables


Thanks for that Ray...it seems to work.
Im having problems with the DSSetParam in that it returns -4 - not happy with the value being set - even though the Parameter is type String.
Locked