Why "$ read name < file_name" doesn't work in sh script ?

Why "$ read name < file_name" doesn't work in sh script ?

Post by Dragon F » Fri, 14 May 1993 01:29:05



What makes me wonder is why the command (I mean sh-shell)
$ read name < file_name
doesn work ?
It answers "illegal i/o".

S.V.

 
 
 

Why "$ read name < file_name" doesn't work in sh script ?

Post by Michael Bernste » Fri, 14 May 1993 04:45:39


DF> What makes me wonder is why the command (I mean sh-shell)
DF> $ read name < file_name
DF> doesn work ?
DF> It answers "illegal i/o".

Yeah, how come?  It works fine in ksh and bash, but not in bourne shell.

Michael Bernstein

It is amazing how few people are conscious of the art of lying in bed.
        -- Lin Yutang

 
 
 

Why "$ read name < file_name" doesn't work in sh script ?

Post by Chet Ram » Fri, 14 May 1993 22:55:11




>DF> What makes me wonder is why the command (I mean sh-shell)
>DF> $ read name < file_name
>DF> doesn work ?
>DF> It answers "illegal i/o".

>Yeah, how come?  It works fine in ksh and bash, but not in bourne shell.

The v7 sh, which lives on in Ultrix and 4.3 BSD as /bin/sh, does not
allow redirection with shell builtins.  That ability was added somewhere
between v7 and SVR2.

Chet
--
       ``He is asleep.  Though his mettle was sorely tried, He
         lived, and when he lost his angel, died.  It happened
         calmly, on its own.  The way night comes when day is done.''

 
 
 

1. Why doesn't echo "text" 'command' "more text" work?

                 ^                                        ^
Wrong quotes, should be -
   echo "You have" `grep Subject: /usr/spool/mail/me | wc -l` "messages."
or -
   echo "You have `grep Subject: /usr/spool/mail/me | wc -l` messages."

But, another problem is, if you've no mail, /usr/spool/mail/me does not
exist, leading grep to say:
   grep: can't open /usr/spool/mail/me
Wc will still report 0.

You might try -
   sh -c 'echo "You have `grep 2>/dev/null Subject: /usr/spool/mail/me | wc -l` messages."'

Hope this helps.

2. Xephem 2.5 BINARIES

3. sched - system calls

4. why "read" doesn't work in my script?

5. Recompiling Kernel results abnormal errors (With Ram Upgrade)

6. ftp in script works until imbedded in loop then receive "`<<' unmatched"

7. Dual Boot with two disks...

8. FTP works, but "ls" or "dir" doesn't ???

9. bash/sh "exec" problem - startx doesn't work

10. option "root=" doesn't work with devfs device names

11. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

12. Why doesn't "ls -dlR" work?