It is currently Tue, 17 May 2022 01:26:15 GMT



 
Author Message
 Kornshell typeset command behaves unusually under AIX 3?

I'm just now dealing with my first AIX box, and a simple
script designed to zero-fill fields is bombing.

Here's the script:

#!/bin/ksh
typeset -Z -R4 store
while read storenum
do
        store=$storenum
        print $store >> dalfstor
done < dalfstor.txt

It takes input like:

1
4
666
9324
42

        and makes it:

0001
0004
0666
9324
0042

...except on this AIX box, where this just doesn't work. Nothing in the
FAQ, so I thought I'd ask in these two groups before I cobbled up some ridiculous string manipulator. Anyone?

        John Adams

...does not speak for his favorite employer, NCR Corporation, today...



 Sat, 27 Nov 1999 03:00:00 GMT   
 Kornshell typeset command behaves unusually under AIX 3?

In comp.unix.aix John Adams <John.Ad...@BentonvilleAR.ncr.com> wrote:

I assume the problem you have is that the done doesn't like the < dalfstor.txt

remove it and:

        # Program-name < dalfstor.txt

--

Simon Travaglia,  Email without auto spam rejection at s...@waikato.ac.nz
http://mrjolly.cc.waikato.ac.nz Ph: +64 7 838-4709 Fax: +64 7 838-4066
  University of Waikato, Private Bag 3105, Hamilton, New Zealand..



 Sun, 28 Nov 1999 03:00:00 GMT   
 Kornshell typeset command behaves unusually under AIX 3?

|In comp.unix.aix John Adams <John.Ad...@BentonvilleAR.ncr.com> wrote:
|> I'm just now dealing with my first AIX box, and a simple
|> script designed to zero-fill fields is bombing.
|
|> Here's the script:
|
|> #!/bin/ksh
|> typeset -Z -R4 store
|> while read storenum
|> do
|>         store=$storenum
|>         print $store >> dalfstor
|> done < dalfstor.txt
|
|
| I assume the problem you have is that the done doesn't like the < dalfstor.txt
|
| remove it and:
|
|       # Program-name < dalfstor.txt

It's kind of hard to know what problem he has, isn't it?  There really
isn't anything wrong with it - the block input redirection is perfectly OK.
Why do you assume that's the problem?  Have you tried it?

In fact I tried this exact script on AIX 4.2 and AIX 3.2.5, with no
apparent problems.  Numbers longer than 4 digits are truncated - is that
what he objects to?  Don't know, all he said was that it didn't work.

The typeset command is a little redundant:  -Z -R4 is the same as -Z4.
That could be something to try, but it's probably not the problem either.
One of ksh's main advantages is that, apart from things that were done
on purpose (e.g. "echo"), it's fairly consistent between one platform
and another, so if our correspondent here had this working somewhere else,
then the problem is probably something he's not showing us.

        Donn Cave, University Computing Services, University of Washington
        d...@u.washington.edu
--------
Today's fun spelling tip:

    To lose, to have lost, to suffer loss.  However the vowel may sound,
    it's spelled with only one "O".  Loose is a different word.



 Sun, 28 Nov 1999 03:00:00 GMT   
 Kornshell typeset command behaves unusually under AIX 3?

Well, thanks, but I'd tried that, and it didn't fix me.

Here's a bit of the result:

 ksh -x fourdigit < dalfstor.txt
+ typeset -Z -R4 store
+ read storenum
+ store=23
+ print 3
+ 1>> dalfstor
+ read storenum
+ store=33
+ print 3
+ 1>> dalfstor
+ read storenum
+ store=868
+ print 68
+ 1>> dalfstor
+ read storenum
+ store=8299
+ print 299
+ 1>> dalfstor

Input           Output          Should Be

23              3               0023
33              3               0033
868             68              0868
8299            8299            8299

("Should Be" is the way it works elsewhere.)

The results are the same whether I change the redirection or not.

Changing from:

        typeset -Z -R4 store

to:

        typeset -Z -L4 store

does improve the result, by the way:

Input           Output          Should Be

23              23              0023
33              33              0033
868             868             0868
8299            8299            8299

...but still doesn't get me what I want.

The -Z option is what's not working here, I believe. But I have
*no* documentation for this system, and don't really want to try
making a little spinner to run through every possible option till
I get what I want...unless I have to.

Anyone know what's going on here? I sure don't.

        John Adams
        ...does not speak for his favorite employer, NCR Corporation



 Sun, 28 Nov 1999 03:00:00 GMT   
 Kornshell typeset command behaves unusually under AIX 3?

just some feedback.... there is nothing wrong with the following
construct

while read someVariable
do
        doSomething
done < someFile

it a simple method of painting preconfigured menus on the screen and
otherwise
reading files line by line...

you can also have multiple variables, as in:

while read var1 var2 var3
do
...
done < someFile

--
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/_/_/ email address altered to avoid SPAMMERS  _/_/_/
_/_/_/ try kaizen-at-maxinet-dot-com            _/_/_/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



 Sun, 28 Nov 1999 03:00:00 GMT   
 Kornshell typeset command behaves unusually under AIX 3?

: >
: > In comp.unix.aix John Adams <John.Ad...@BentonvilleAR.ncr.com> wrote:
: > > I'm just now dealing with my first AIX box, and a simple
: > > script designed to zero-fill fields is bombing.
: > ...
: The -Z option is what's not working here, I believe. But I have
: *no* documentation for this system, and don't really want to try
: making a little spinner to run through every possible option till
: I get what I want...unless I have to.
:
: Anyone know what's going on here? I sure don't.

Ah! then this should help (snipped from info)

  -Z     Right-justifies and fills with leading zeros if the first nonblank
  character is a digit and the -L flag has not been set.  If the n parameter
  has a nonzero value, it defines the width of the field; otherwise, it is
  determined by the width of the value of its first assignment.

Try something like:  "typeset -Z5 store"

--

   Dweeberly Loom



 Sun, 28 Nov 1999 03:00:00 GMT   
 Kornshell typeset command behaves unusually under AIX 3?

This works fine on my 3.2.5 system -- both your example and some
other uses of typeset -Z I cooked up on my own.  I suspect you need
some ksh PTF.

I'd check the output of "oslevel -q" to see if you have any of the
3.2.5.101 PMP (Preventative Maintenance Package) installed; I have
most of it on my machine.  It will show up as "325101" in the list
of known levels.  If oslevel knows about 325101, you can use
"oslevel -m 325101" to see if you're missing any PTFs from that
level.  Look for bos.obj PTFs for ksh.

If you don't have 3.2.5.101, I'd suggest either installing it or
checking fixdist for ksh-specific patches.  See the FAQ for more
information.

Michael Wojcik                                          m...@microfocus.com
AAI Development, Micro Focus Inc.
Department of English, Miami University



 Sun, 28 Nov 1999 03:00:00 GMT   
 
   [ 7 post ] 

Similar Threads

1. typeset command, what it does ?

2. Info reqd. on TYPESET command

3. recall of previous command tokens in bash or kornshell

4. vi set commands using kornshell

5. The /New/ KornShell Command and Programming Language

6. rpcgen behaves different than under AIX, server compile fails

7. ldd command behaves differently on different machines...

8. tcsh and keys not behaving on AIX

9. Need an AIX comand that is similar to Linix ipchains command or freeBSD ipfw command

10. Making perl a builtin command dtksh command on AIX 4.x


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software