Help with shell script which logins to hosts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with shell script which logins to hosts
# 1  
Old 05-20-2010
Help with shell script which logins to hosts

By a shell script When I am logging into hosts one by one with ssh.
I am getting below message.

Code:
 Pseudo-terminal will not be  allocated because stdin is not a terminal.
 stty: : Invalid  argument
 stty: : Invalid  argument

Can you please suggest what should I do to stop this?

Code:
 Code  for ssh
 for i in 0 1 2 3  4 5 6 7 8 9 10
 do
 ssh  ${HTNM[$i]} <<EOF
       if [ -f  file ];then
 XYZ
 else
 ABC
        fi
 exit
 EOF
 done

Thanks

Last edited by pludi; 05-21-2010 at 03:49 AM.. Reason: cleaned up formatting
# 2  
Old 05-20-2010
How are you calling your script?

Probably you are looking for "-t -t" flags.
# 3  
Old 05-21-2010
I am calling/running the script as
./LoginHosts

HTNM is a array which contains host names like

Code:
HTNM_ARR="host-app-dev-03 host-app-dev-04 host-app-dev-02"
set -A HTNM $HTNM_ARR

this array i am passing to ssh simply. (as given in the loop)

Code:
 for i in 0 1 2
 do
 ssh  ${HTNM[$i]} <<EOF
  echo " i m host ${HTNM[$i]}"
 exit
 EOF
 done

It is perfectly working fine but i am getting the below message with the echo output.

Code:
Pseudo-terminal will not be allocated because stdin is not a terminal.
stty: : Invalid argument
stty: : Invalid argument
i m host host-app-dev-03


Last edited by pludi; 05-21-2010 at 03:46 AM.. Reason: code tags, please...
# 4  
Old 05-21-2010
Try ssh -T paramtetre ..(Disable pseudo-tty allocation)
I think you dont need tty Smilie
# 5  
Old 05-21-2010
Thanks
The first line gone but still 2 coming like below.
Code:
stty: : Invalid argument
stty: : Invalid argument
i m host host-app-dev-03

# 6  
Old 05-21-2010
Quote:
Originally Posted by KuldeepSinghTCS
Thanks
The first line gone but still 2 coming like below.
Code:
stty: : Invalid argument
stty: : Invalid argument
i m host host-app-dev-03

Code:
#!/bin/bash
HTNM_ARR=("host-app-dev-03" "host-app-dev-04" "host-app-dev-02")
for i in 0 1 2
  do
    HTNM=${HTNM_ARR[i]}
     ssh -T "$HTNM" <<EOF
      echo "i m"  `hostname -s`
EOF
  done

# 7  
Old 05-21-2010
Try "ssh -Tq"

Also, verify that you are not using some tty-only options in your shell rc file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh. Actions to perform within a single ssh session via shell script - copy a file - untar at destination (remote host) OS : Linux RHEL6 (3 Replies)
Discussion started by: sankasu
3 Replies

2. Shell Programming and Scripting

Ssh to 100s of hosts with password in a shell script or text file

I have about 500 hosts where I need to ssh by sending the password on the command line or in a text file in a clear text . However I am not able to download "sshpass" or other tools . Any other ways to pass the password in a script ? (3 Replies)
Discussion started by: gubbu
3 Replies

3. Linux

Shell ${1:-/etc/hosts} meaning

Hello. In some script, I saw: filename=${1:-/etc/hosts} if && ; then md5sum $filename else echo “$filename can not be processed” fi # Show the file if possible ls -ld $filename 2>/dev/null What does the first line means? In $filename I still got /etc/hosts. (2 Replies)
Discussion started by: lozicd3
2 Replies

4. AIX

aix tcp wrappers hosts.allow hosts.deny?

hi all just installed the netsec.options.tcpwrapper from expansion pack, which used to be a rpm, for my aix 6.1 test box. it is so unpredictable. i set up the hosts.deny as suggested for all and allow the sshd for specific ip addresses/hostnames. the tcpdchk says the hosts allowed and... (0 Replies)
Discussion started by: wf201626
0 Replies

5. Shell Programming and Scripting

Script that outputs user logins sorted by duration

Hello, I want to write a script that takes a username as input and outputs the user's logins sorted by duration. Also I want to exclude the "still logged in" entries. I use the "last" command but Im having problems sorting the entries based on the duration. Can you help me? Thanks a lot =) (4 Replies)
Discussion started by: ddante
4 Replies

6. Shell Programming and Scripting

Shell Scripting.... How to start a same script in 3 different logins?

Hi, I’ve a shell script. If I trigger the script it takes one day to complete the execution. I’ve to start the same script in 3 different logins of Unix machine simultaneously. Do you have any idea how can I make it? Please suggest. Thank you.. Stop making the font size smaller than... (3 Replies)
Discussion started by: testin
3 Replies

7. Shell Programming and Scripting

Emergency...!!! Shell Scripting.... How to start a same script in 3 different logins?

Hi, I've a shell script. If I trigger the script it takes one day to complete the execution. I've to start the same script in 3 different logins of Unix machine simultaneously. Do you have any idea how can I make it? Please suggest.:( Thank you.. (1 Reply)
Discussion started by: testin
1 Replies

8. Shell Programming and Scripting

Run a script in two differnt logins

Hi, I need to run a script in two different login's in the same server, but it is running only in one login, i have used the corresponding PATH for each login, but still it says " not authorized to put msg in queue". (2 Replies)
Discussion started by: savithavijay
2 Replies

9. Shell Programming and Scripting

Another question for tracking failed logins via script

Hello Experts, I have this initial shell script that tracks failed login attempts: #!/bin/bash #Fetch failed user logins to file failed-logins.txt grep -i failed /var/log/secure | awk '{ print $1, $2" ", $3" ", $9" ", $11 }' > failed-logins.txt #Splitting the failed-logins in... (10 Replies)
Discussion started by: linuxgeek
10 Replies

10. Shell Programming and Scripting

Last two logins script

This is the contents of my file: donald.duck 12/07/2009 12:07:58 donald.duck 12/07/2009 12:17:36 donald.duck 12/07/2009 12:22:29 donald.duck 12/07/2009 12:26:39 donald.duck 12/07/2009 12:28:01 mickey.mouse 12/07/2009 12:48:49 mickey.mouse 12/07/2009 12:49:33 mickey.mouse 12/07/2009... (3 Replies)
Discussion started by: diallo0024
3 Replies
Login or Register to Ask a Question