From: invincible on
I am trying to read from a file for the list of servers and then
instruct the script to login on these servers and run a command to
check one text file.

So far its done the below way...

cat server-list | \
while read line
do
echo "------------------------------------------------" >>test.out
echo " HOST : $line" >>test.out
echo "________________________________________________" >>test.out
rsh $line cat /home/basks.tbl|awk '{ print $1 }' >>test.out
done

The problem seems to be that script does not work !!! :-)

Any ideas around using cat wiht the while loop in a better way ?
From: Florian Kaufmann on
> rsh $line cat /home/basks.tbl|awk '{ print $1 }' >>test.out

Maybee you have to write

rsh "$line" cat ...

because $line might contain blanks.
From: Ed Morton on


On 4/22/2008 8:09 AM, invincible wrote:
> I am trying to read from a file for the list of servers and then
> instruct the script to login on these servers and run a command to
> check one text file.
>
> So far its done the below way...
>
> cat server-list | \
> while read line
> do
> echo "------------------------------------------------" >>test.out
> echo " HOST : $line" >>test.out
> echo "________________________________________________" >>test.out
> rsh $line cat /home/basks.tbl|awk '{ print $1 }' >>test.out
> done
>
> The problem seems to be that script does not work !!! :-)
>
> Any ideas around using cat wiht the while loop in a better way ?

Yes, don't use it. Instead of this:

cat file |
while read line
do
whatever
done

do this:

while IFS= read -r line
do
whatever
done < file

and instead of this:

cat file | awk '...'

do this:

awk '...' file

So, do that and then post a followup if your script still doesn't work.

Ed.

From: Bill Marcum on
On 2008-04-22, invincible <imanuk2007(a)googlemail.com> wrote:
>
>
> I am trying to read from a file for the list of servers and then
> instruct the script to login on these servers and run a command to
> check one text file.
>
> So far its done the below way...
>
> cat server-list | \
> while read line
> do
> echo "------------------------------------------------" >>test.out
> echo " HOST : $line" >>test.out
> echo "________________________________________________" >>test.out
> rsh $line cat /home/basks.tbl|awk '{ print $1 }' >>test.out
> done
>
> The problem seems to be that script does not work !!! :-)

How does it not work? What errors do you get? Are you sure rsh on your
system is "remote shell" and not "restricted shell"?
Another possible problem is that rsh is in a loop with a pipe as
standard input. You might need to redirect the rsh command's input to
/dev/null.

>
> Any ideas around using cat wiht the while loop in a better way ?
From: invincible on
On Apr 22, 2:49 pm, Ed Morton <mor...(a)lsupcaemnt.com> wrote:
> On 4/22/2008 8:09 AM, invincible wrote:
>
>
>
> > I am trying to read from a file for the list of servers and then
> > instruct the script to login on these servers and run a command to
> > check one text file.
>
> > So far its done the below way...
>
> > cat server-list | \
> > while read line
> > do
> > echo "------------------------------------------------" >>test.out
> > echo " HOST : $line" >>test.out
> > echo "________________________________________________" >>test.out
> > rsh $line cat /home/basks.tbl|awk '{ print $1 }' >>test.out
> > done
>
> > The problem seems to be that script does not work !!! :-)
>
> > Any ideas around using cat wiht the while loop in a better way ?
>
> Yes, don't use it. Instead of this:
>
> cat file |
> while read line
> do
> whatever
> done
>
> do this:
>
> while IFS= read -r line
> do
> whatever
> done < file
>
> and instead of this:
>
> cat file | awk '...'
>
> do this:
>
> awk '...' file
>
> So, do that and then post a followup if your script still doesn't work.
>
> Ed.

Ed,

It seems Im now stuck on below error

rsh dubba awk '{ print $1 }' /home/basks.tbl
syntax error The source line is 1.
The error context is
>>> { <<<
awk: The statement cannot be correctly parsed.
The source line is 1.

Thankyou