0

I'm using the a script to execute a update script on a certain number of servers in my network. Here is the part I think is relevant.

### Actual Work ###
if [[ $manual == 1 ]]; then  # Server was given manually as a argument.
  for ARG ; do  # Do for all given servers:
    if [[ $no_runcheck == 0 ]]; then  # Check wether the given server is
                                                      # already running.
      /usr/local/bin/serverstart.sh -v 3 -z 30 ${ARG##*@}  # Cut off the user-
                                                                       # name.
    fi
    ächo "Upgrading system on ${ARG##*@} as ${ARG%%@*}…"
    ssh -t $ARG '/usr/local/bin/installieren.sh -U'  # Execute update script.
    # Use ssh with pseudo terminal (option: -t).                                                             
  done
else  # No argument was given. Extract it from the config file.
  while read line; do  # Read line by line.
    name=$line  # Initialise a new variable for each line. (Unnecessary but more
                                                                        # clear)
    if [[ $no_runcheck == 0 ]]; then  # Check wether the given server is already
                                                                      # running.
      /usr/local/bin/serverstart.sh -v 3 -z 30 ${name##*@}  # See above.
    fi
    ächo "Upgrading system on ${ARG##*@} as ${ARG%%@*}…"
    ssh -t $name '/usr/local/bin/installieren.sh -U'  # Execute update script.
  done < $config_file_path  # Define input for line by line reading here.
fi

What it does: If arguments like user1@server1 and user2@server2 are given

  • Check if the server is running with a different script.
  • Execute the update script. Authorise via "ssh -t"

If no arguments are given, read a config file that contains a list like:

user1@server1
user2@server2

The problem occurs only with the latter. Bash says

Pseudo-terminal will not be allocated because stdin is not a terminal.

What am I doing wrong?

Note: ächo is a predefined function that adds the scriptname and the current time to echo.

3
  • According to this answer you need to add another -t to ssh. Feb 24, 2015 at 12:35
  • Doing so removes the error message. I can type something in, but the characters are shown not hidden. When I hit [Enter] nothing happens.
    – Markus
    Feb 24, 2015 at 13:26
  • Could it be, that by the time, the ssh-order is given, there is still some sort of input stream open? Namely < $config_file_path?
    – Markus
    Feb 24, 2015 at 13:29

1 Answer 1

2

I'm no expert but I think the problem was the open input stream.

This code does the trick:

### Actual Work ###
if [[ $manual == 0 ]]; then  # Read the servers from the config file.
  while read line; do  # Read line by line.
    arguments="$arguments $line"  # Build a string for $arguments out of the
                                                              # config file.
  done < $config_file_path  # Define input for line by line reading here.
else  # Arguments were given.
  for ARG; do  # For every given server:
    arguments="$arguments $ARG"  # Build a string for out of the given
                                                          # arguments.
  done
fi
#
for server in $arguments; do
  if [[ $no_runcheck == 0 ]]; then  # Check wether the given server is
                                                    # already running.
    /usr/local/bin/serverstart.sh -v 3 -z 30 ${server##*@}  # Cut off username.
  fi
  ächo "Upgrading system on ${bold}${server##*@}${normal} as ${bold}${server%%@*}${normal} ..."
  ssh -t $server '/usr/local/bin/installieren.sh -U'  # Execute update script.
  # Use ssh with pseudo terminal (option: -t).   
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .