"tr" command not working properly in test environm

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
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

"tr" command not working properly in test environm

Post by mdbatra »

Hi All
we are having an issue in one of the DS env(test) where in "tr" commands in scripts are not getting parsed correctly causing failures.

To deal with that, I made a trivial script that inputs an argument and converts it into uppercase using "tr" (like in actual scripts) as below:

COUNTRY_CODE=$1
which tr
set
echo $COUNTRY_CODE
COUNTRY_CODE=`echo ${COUNTRY_CODE} | tr [a-z] [A-Z]`
echo $COUNTRY_CODE

and it's giving the same error in log, as below:

_=tr
ab
Usage: tr [ -cds ] [ String1 [ String2 ] --where "ab" was the input argument to script.

"tr" works fine as such on unix. Also, exported job to UAT and it works fine there. The only difference i could see is that in UAT, it runs as bourne shell(sh) while in test, it runs as ksh. Default shell on both servers is ksh but dsenv file is setting the default as bourne(using and both dsenv files are same(being generic).

Have couple of questions here:
1. what could be the reason that shell is not set to bourne in test env?
2. when i see the 'enviornment variable settings' event in log: I see shell only in test(as ksh) but SHELL variable is not thrown in UAT. I had to use "set" in the test script(as above) to see what shell is being used. why is it so ?

any help would be appriciated.
Rgds,
MB
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea: Try using the [:lower:] and [:upper:] classes instead.

The default shell is set in the operating system, via the SHELL environment variable and via the login process (in which case the SHELL environment variable may not be set). Check the .profile script for the user under which connections are made, as well as the global /etc/profile file. Presumably your two systems have been set up differently.

Different UNIXes have different defaults, too, for example the Linux default is bash (Bourne again shell). So, if your environments are different UNIXes...
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

Hi Ray

problems are:
1. already, around 70-80 scripts are in place which use the "tr" in some or the other way. Hence, even in [:lower/:upper] works in that trivial script, it would be a pain to do same in all the others existing. Looking if something could be done w/o change in scripts, at unix or DS level.

2. Changing of scripts would leave the test env out of sync as compared to UAT/PROD environment , unless all scripts are migrated and tested again in both the later environments.

On a different note: guess, have survived on free membership for quite long but high time for premium membership now :)
please let me know within how much time it could be acquired?
Rgds,
MB
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

ah, i see it as 48 hrs, fine with me :) have applied for it now. waiting eagerly :P
Rgds,
MB
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

You can set the shell that will execute the script by putting a line at the top of the script.
#!/bin/sh
Or
#!/bin/ksh
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

hi Tony...surprisingly, that line is already there...but somehow not not being able to set
Rgds,
MB
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

Are you saying that even though it's there, it's not using that shell? Or that you cannot change the line in the file? Or something else?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

For grins, verify that that is indeed the actual location of the shell on your O/S.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

Hi Tony-- yes, I meant it's not using that line ( to set to bash shell) somehow even though it's present there(as a standard it's there in each and every script for the project )

few other observations:
1. .profile and .dsenv are same across all the projects (ST/UAT/PROD)
2. few other ST projects exist on the same server as of the problematic project. If I login to a different project but using same generic user id and run the same job/script (after importing from the actual ST project) , it runs perfectly fine :roll:

so it has come narrowed down to a project level issue rather than a server/login/shell related issue.

any clues, why ?
Rgds,
MB
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

Hi Craig...i verified that as well...it is indeed.
Rgds,
MB
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

did you check if there is anything in the $HOME/.profile file of the user id ( unix id ) used to run jobs in the troublesome project ?
Post Reply