okay heres part of code when ssh servers server.txt list.
while read server <&3; #read server names while loop servername=$(uname -n) if [[ ! $server =~ [^[:space:]] ]] ; #empty line exception continue fi echo server on list = "$server" echo server signed on = "$servername" if [ $servername == $server ] ; #makes sure server doesnt try ssh continue fi echo "connecting - $server" ssh "$server" #ssh login echo connected "$servername" exec < filelist.txt while read updatedfile oldfile; # echo updatedfile = $updatedfile #use troubleshooting # echo oldfile = $oldfile #use troubleshooting if [[ ! $updatedfile =~ [^[:space:]] ]] ; #empty line exception continue # empty line exception fi if [[ ! $oldfile =~ [^[:space:]] ]] ; #empty line exception continue # empty line exception fi echo comparing $updatedfile $oldfile if diff "$updatedfile" "$oldfile" >/dev/null ; echo files compared same. no changes made. else echo files compared different. cp -f -v $oldfile /infanass/dev/admin/backup/`uname -n`_${oldfile##*/}_$(date +%f-%t) cp -f -v $updatedfile $oldfile fi done done 3</infanass/dev/admin/servers.txt
i keep on getting error , ssh doesn't connect , perform code on server suppose ssh'd on.
pseudo-terminal not allocated because stdin not terminal
i feel guy above said wrong.
expect?
it's simple:
ssh -i ~/.ssh/bobskey bob@10.10.10.10 << eof echo creating file called apples in /tmp folder touch /tmp/apples exit eof
everything in between 2 "eof"s run in remote server.
the tags need same. if decide replace "eof" "waynegretzky", must change 2nd eof also.
Comments
Post a Comment