I have next script:
for dom0 in host1 host2
do
if nc -z $dom0 22;
then
ssh root@$dom0 <<EOS
[ -f /usr/sbin/xm ] &&
xm info | awk '
BEGIN { printf "$dom0 "; }
/total_memory/ { printf "%d ", \$3}
/free_memory/ { print \$3 }'
EOS
else
echo "$dom0 no responde"
fi
done
When I run it:
$ ./script
host1 4093 181
stdin: is not a tty
host2 4093 145
If I change here document to doubled quoted string it works without
warning
How can I disable this warnings ? Any workaround?
Thanks
try
ssh -T root@$dom0
Thanks for your time
Regards
It's got to do with "t", in lower case.
man ssh said:
"
-T Disable pseudo-tty allocation.
-t Force pseudo-tty allocation. This can be used to execute
arbitrary screen-based programs on a remote machine, which can be very
useful, e.g., when implementing menu services. Multiple -t options
force tty allocation, even if ssh has no local tty.
"
with -t I get again the same issue.
with -t -t I get:
tcgetattr: Inappropriate ioctl for device
and then it seems like understand "\t" into host1 (it showed me about
host1 files auto-complete feature)
Thanks
What shell does "root" have on the two remote hosts?
Typically this message comes from a command being placed in a shell
startup file (e.g. ~root/.bashrc on the remote hosts) that should not be
there. The most common is something like "stty erase ^?".
It is running bash on both servers.
With your tip my problem changed to:
$ ssh root@host1 <<EOF
> echo \$PS1
> EOF
$ ssh root@host2 <<EOF
> echo \$PS1
> EOF
stdin: is not a tty
\h:\w\$
But I can't find which is te diff between root@host1 bash session
files and root@host2
I tried to compare:
bash.bashrc bash_completion .bash_history .bash_profile .bashrc
profile
And too /etc/pam.d directory ( I think I compared all /etc/ dir with
meld)
Only export sentences (to set environment variables) are different
In ~/.bashrc i tried comment:
export PS1='\h:\w\$ '
but the result was:
$ ssh root@host2 <<EOF
> echo \$PS1
> EOF
stdin: is not a tty
I tried ssh with pipe, and too appears the same issue:
echo "ls" | ssh root@host2
stdin: is not a tty
echo "ls" | ssh root@host1
ok
Have you got any tip more?
Thanks you!
And it were on .bash_profile who exists on host1 and not in host2 !!!
on my .profile reads:
mesg n
and this command was who tell 'is not a tty'
I didn't know about if .bash_profile exist .profile is not read.
So, should I modify in .profile to:
mesg n 2> /dev/null
Or are there any other better tip?
Thank you!
#!/bin/bash
#name: awk_script
[ -f /usr/sbin/xm ] &&
xm info | awk '
BEGIN { printf "$dom0 "; }
/total_memory/ { printf "%d ", $3}
/free_memory/ { print $3 }'
---
and then
#!/bin/bash
#name: "client"_script
if nc -z $dom0 22;
then
ssh root@$dom0 awk_script
else
echo "$dom0 no responde"
fi
---
?
Then If you have n servers, you need to maintain n scripts (or push
any changes on the script to them from some script).
I used your method with others scripts
I don't know which is the prefer/best method
Do you recommend cfengine or puppet for doing such things ?
You could also try replacing the line with
[ -t 0 ] && mesg n
to test if the input is a terminal.