Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer > Re: Odd ksh pro...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 1000 of 1040
Post > Topic >>

Re: Odd ksh problem

by Robert Peirce <bob@[EMAIL PROTECTED] > Mar 2, 2008 at 04:17 PM

In article <nospam.News.Bob-3DD5EC.20413701032008@[EMAIL PROTECTED]
>,
 Bob Harris <nospam.News.Bob@[EMAIL PROTECTED]
> wrote:

> In article <bob-4638D5.12045601032008@[EMAIL PROTECTED]
>,
>  Robert Peirce <bob@[EMAIL PROTECTED]
> wrote:
> 
> > In article <nospam.News.Bob-166AC4.20065929022008@[EMAIL PROTECTED]
>,
> >  Bob Harris <nospam.News.Bob@[EMAIL PROTECTED]
> wrote:
> > 
> > > In article <bob-A604BE.14425829022008@[EMAIL PROTECTED]
>,
> > >  Robert Peirce <bob@[EMAIL PROTECTED]
> wrote:
> > > 
> > > > data $1 |
> > > > tr : '\t' |
> > > > field 1 3 4 |
> > > > tail -200 |
> > > > 
> > > > while read -r line
> > > > do print -r -- $line
> > > > done
> > > 
> > > why not try
> > > 
> > > data $1 | awk -F: '{print $1, $3, $4}' | tail -200
> > 
> > No reason.  I just tried to run the script as it sat. I figured I
would 
> > worry about changing it once I got it working.  Besides, this change 
> > doesn't make the while loop work.
> > 
> > The main question was why can't I pipe information into a ksh while
loop 
> > on my Mac when I can do it on other Unix installations?  This is made 
> > more confusing to me by the fact that the following does work:
> > 
> > . . .
> > tail -200 > tmp-file
> >  
> > exec 0< tmp-file
> > while read -r line
> > . . .
> > 
> > From my point of view, stdin is stdin and a pipe should work here.
> 
> Well, why not try a different shell.  For example instead of ksh, 
> try bash or zsh.  The 'while', the 'read' and the stdin 
> redirection is a function of the shell.  Perhaps it is your shell 
> that is having problems.

Thanks, Bob, but that defeats the purpose of trying to figure out why 
this doesn't work when it should.  In an earlier version of this script 
I used awk for everything.  I switched to ksh because the built-ins 
allowed me to do everything directly in the shell so I didn't have to 
call other programs.
 
> If the behavior works with a different shell, then check the 
> version of ksh on Mac OS X vs the other Unix systems you use.  On 
> Tiger I'm seeing:
>   version         sh (AT&T Labs Research) 1993-12-28 p
> and Leopard is showing:
>   version         sh (AT&T Research) 1993-12-28 s+
> 
> Mac****ts says it has the following 2 versions of ksh
> ksh93                          @[EMAIL PROTECTED]
     shells/ksh93
> pdksh                          @[EMAIL PROTECTED]
         shells/pdksh
> 
>                                         Bob Harris

The version I am running at the office is 1993-12-28 q.  It is possible 
the pipe-to-while capability was added in q and did not exist in p.

I found www.mac****ts.org, but I cannot figure out if there is a way just 
to get ksh93 without installing the whole Mac****ts package, so I am 
going to do that and try to get there version of ksh93.

-- 
Robert B. Peirce, Venetia, PA  724-941-6883
bob AT peirce-family.com [Mac]
rbp AT cooksonpeirce.com [Office]
 




 6 Posts in Topic:
Odd ksh problem
Robert Peirce <bob@[EM  2008-02-29 19:42:58 
Re: Odd ksh problem
Robert Peirce <bob@[EM  2008-02-29 20:52:09 
Re: Odd ksh problem
Bob Harris <nospam.New  2008-03-01 01:07:27 
Re: Odd ksh problem
Robert Peirce <bob@[EM  2008-03-01 17:04:56 
Re: Odd ksh problem
Bob Harris <nospam.New  2008-03-02 01:42:06 
Re: Odd ksh problem
Robert Peirce <bob@[EM  2008-03-02 16:17:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 9:18:27 CST 2008.