cancel
Showing results for 
Search instead for 
Did you mean: 

AT&T Ksh Timezone bug

 
Michael Williams_6
Trusted Contributor

AT&T Ksh Timezone bug

Hello all!

We've downloaded the AT&T ksh as pdksh doesn't not have sufficient functionality for our scripting needs.

Unfortunately for us, this ksh has a built-in for date which has a bug in it and so isn't picking up that the clocks changed last month.

We can get around this by adding an alias date=/bin/date in the .profile or .kshrc, however, when someone runs a script with #!/bin/ksh at the top, then this information is not passed on to the sub-shell.

Does anyone know how to export aliases, like environmental variables?

Alternatively, can someone suggest a solution that will work with sub-shells?
18 REPLIES 18
Roberto Polli
Trusted Contributor

Re: AT&T Ksh Timezone bug

being bash a ksh compliant shell you can try to link ksh to bash.

I use it and scripts run fine.
Else try to put an alias to date in the script or specify full path.

Peace, R.
Nicolas Dumeige
Esteemed Contributor

Re: AT&T Ksh Timezone bug

Hello,

One correction if you let me : pdksh is NOT the ATT Korn Shell, it's a clone developped before ksh could be freely downloaded.

It has limitations that the original one have not.

The real ksh is downloadable at :
http://www.research.att.com/sw/download/gen/ast-ksh.html

Cheers

Nicolas
All different, all Unix
Michael Williams_6
Trusted Contributor

Re: AT&T Ksh Timezone bug

Unfortunately bash has the same limitation as pdksh, we have to use AT&T's ksh.
Roberto Polli
Trusted Contributor

Re: AT&T Ksh Timezone bug

Sorry! Can you explain which kind of limitation you have found for bash and pdksh?

Peace, R.
Steven E. Protter
Exalted Contributor

Re: AT&T Ksh Timezone bug

If you have to use it, you have to work with the bug. I think attempts to bring the korn shell to Linux are half-baked at best.

I have found that /bin/sh has run correctly almost all of my korn shell based scripts that I was forced to port from hp-ux to Linux.

Just a thought.

You could also handle such issues as timezone by setting a variable globally in all scripts that lets them calculate from there.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Nicolas Dumeige
Esteemed Contributor

Re: AT&T Ksh Timezone bug

Roberto,

Try that one :
pdksh> echo value | read var ; echo $var
<-- Null
ksh> echo value | read var ; echo $var
value

Nicolas
All different, all Unix
Bruce Copeland
Trusted Contributor

Re: AT&T Ksh Timezone bug

Let me see if i have this straight. You want

echo value | read var; echo $var

to mean

echo value | (read var; echo $var)

instead of

(echo value | read var); echo $var

Ie. you want the | operator to take precedence over ; I'm no scripting guru, but this is at odds with most standard programming languages and is one reason many serious programmers are not very fond of scripting. Why not simply bite the bullet and find another way (for example, using parentheses)?

Bruce
Stuart Browne
Honored Contributor

Re: AT&T Ksh Timezone bug

Bruce, nah. The issue Nicholas is talking about has to do with most GNU shells treating pipes as sub-shells, thus not propergating variable changes back up to the parent.

There's ways around that, i.e.:

read var < <(echo blah)

But that's an aside.

If the AT&T ksh implementation has a borked inbuilt 'date', then do one of two things.

- ensure that all of your scripts which will use it use fully pathed commands: /bin/date

- force the hash-bang calls to initiate a login-shell, thus processing /etc/profile etc. so you can force your own aliases.
One long-haired git at your service...
Michael Williams_6
Trusted Contributor

Re: AT&T Ksh Timezone bug

Hi Stuart, going through all our scripts in CVS to ensure they have the line alias /bin/date might take a bit of time, so I like the look of option 2, how to I tell the OS to run the profile with scripts that have #!/bin/ksh at the top?

Mike