OT: shell scripting problem
kevin.kempter at dataintellect.com
kevin.kempter at dataintellect.com
Tue May 17 23:38:46 UTC 2005
On Tuesday 17 May 2005 17:14, linux.whiz at gmail.com wrote:
> On 5/17/05, kevin.kempter at dataintellect.com
>
> <kevin.kempter at dataintellect.com> wrote:
> > You get this behavior because the internal field separator by default
> > recognizes spaces, tebs, etc as field separators.
> >
> > Try this instead (where names.lst is your file of names):
> >
> > exec < ./names.lst
> > while read line
> > do
> > myscript.sh $line
> > done
>
> As soon as I issue the exec < ./names.lst command, my shell exits. My
> understanding is that exec takes over the PID of the current process,
> so when you try to exec a text file it makes sense that the process
> would exit.
>
> Other ideas?
>
> LW
The exec thing usually works for me. Maybe you already have stdin tied up???
Here's a bit of a hokey fix but it should work.
1) make your names.lst file look like this with a dash (-) as a replacement for any spaces
John-A-Smith
Mary-P-James
Sally-R-Jones
Fred-Q-Davis
then do this in your script:
for i in `cat names.lst`; do
username=`echo $i | sed "s/-/ /g"`
myscript.sh $username
done
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20050517/9c1922e0/attachment-0001.htm>
More information about the fedora-list
mailing list