Error Executing the script.

Hi ,
I m getting an error after executing the script.

My script.

Script is used to find out the date on 8 different machines(mentioned in SERVERNAMES file).
I have added public key to avoid ssh password and ssh without password working fine.

#!/bin/sh

fn_VMFind()
{
Date=`ssh -t -t -q root@$1 date`
echo $Date
}

while read line
do
fn_VMFind "$line"
done < SERVERNAMES

There are total 8 Server IP addresses mentioned in SERVERNAMES file.

output:

tcgetattr: Inappropriate ioctl for device
Thu Jul 8 13:59:13 IST 2010

It shows Date on Only first server.
What can be the issue?

You probably want to disable allocating a TTY on the remote site, rather than force it. Use '-T' instead of '-t -t'

fn_VMFind()
{
Date=`ssh -T -q root@$1 date`
echo $Date
}

while read line
do
fn_VMFind "$line"
done < SERVERNAMES

Worked with no error but i m getting a date on first server only what about rest 7.

Seems like sometimes you have to explicitly close SSH's stdin:

Date=$( ssh -T -q root@$1 'date' < /dev/null )

should work

work great but how would i do something like this.
I have done many permutation combination but nothing helped. please suggest.
xm list is a command in Oracle virtual environment and displays name of the machines running under it.
i just want to count the number of lines and assign them to a variable.

VM_COUNT=$(`ssh -T -q root@$1 xm list < /dev/null` | wc -l)

Correct quotes and order go a long way. This should work:

VM_COUNT=$( ssh -T -q root@$1 "xm list" < /dev/null | wc -l)

$() is the modern replacement for backticks.