![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dos-Unix Connectivity | shekhar_ssm | Shell Programming and Scripting | 1 | 01-22-2008 10:54 PM |
| Hummingbird Connectivity Division Releases Connectivity 2008 (EContent Magazine) | iBot | UNIX and Linux RSS News | 0 | 06-17-2007 03:37 PM |
| My sql connectivity | comp_rupesh | Shell Programming and Scripting | 0 | 03-14-2006 10:21 AM |
| Internet connectivity via Win-ICS | Cameron | UNIX for Dummies Questions & Answers | 2 | 09-02-2004 09:11 AM |
| Dos system Connectivity | arulprasad | UNIX for Dummies Questions & Answers | 8 | 02-03-2002 04:17 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
SSH Connectivity script
Hi all,
I have developed a script to list out the servers that is not able to connect to the remote host. The problem with this script is it, if the remote server ask for a password it gets struck there. It works only if the server name is invalid Ex: Lets say ssh -q test@test "exit" < /dev/null the script will throw that test server is invalid. Lets say now UserA and ServerA is valid but when we ssh to the server, it ask for a password and script hangs ssh -q UserA@ServerA "exit" < /dev/null Code Code:
check_ssh()
{
ssh -q $1@$2 "exit" < /dev/null
[ $? -ne "0" ] && return 1 || return 0
}
INP_FILE=Config.ini
for line in $(grep -v "^#" $INP_FILE | cut -d',' -f2,5 | sort | uniq)
do
myUser=$(echo $line| cut -d',' -f2)
myServer=$(echo $line| cut -d',' -f1)
check_ssh $myUser $myServer
[ $? -eq "1" ] && echo "Please check !!! $myServer - $myUser"
done
echo " *** END *** "
exit
|
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
I just want to capture the server names that we are not able to ssh, so that we can skip those servers from executing the command. Hope this makes clear !! |
|
|||
|
Code:
check_ssh()
{
ssh -q -o "BatchMode=yes" $1@$2 "exit" < /dev/null
[ $? -ne "0" ] && return 1 || return 0
}
INP_FILE=Config.ini
for line in $(grep -v "^#" $INP_FILE | cut -d',' -f2,5 | sort | uniq)
do
myUser=$(echo $line| cut -d',' -f2)
myServer=$(echo $line| cut -d',' -f1)
check_ssh $myUser $myServer
[ $? -eq "1" ] && echo "Please check !!! $myServer - $myUser"
done
echo " *** END *** "
exit
|
|||
| Google UNIX.COM |