rlogin01 revision 7c19b82eca3cf012e30d3ae42062cbcef1c9fcbb
1#! /usr/bin/expect -f 2#********************************************************************* 3# Copyright (c) International Business Machines Corp., 2000 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 13# the GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this pronram; if not, write to the Free Software 17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18# 19# 20# 21# FILE : rlogin 22# 23# PURPOSE: Tests the basic functionality of `rlogin`. 24# 25# SETUP: The program `/usr/bin/expect' MUST be installed. 26# The home directory of root on the machine exported as "RHOST" 27# should have a ".rhosts" file with the hostname of the machine 28# where the test is executed, OR the "PASSWD" section below MUST 29# be uncommented and set. 30# 31# HISTORY: 32# 03/01 Robbie Williamson (robbiew@us.ibm.com) 33# -Ported 34# 35# 36# rlogin perform a rlogin session to each host in HOST_LIST with user 37# RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to 38# verify that the rlogin was established. 39# 40#********************************************************************* 41 42set TC rlogin 43set TCtmp "/tmp" 44set SLEEPTIME 3 45set TESTLOG "$TCtmp" 46 47if [info exists env(RUSER)] { 48 set RUSER $env(RUSER) 49} else { 50 set RUSER root 51} 52 53set RHOST $env(RHOST) 54set timeout 10 55 56if [info exists env(LOOPCOUNT)] { 57 set LOOPCOUNT $env(LOOPCOUNT) 58} else { 59 set LOOPCOUNT 25 60} 61 62# stty echo 63send_user " Starting\n" 64 65set count 0 66while {$count < $LOOPCOUNT} { 67 set count [expr $count+1] 68 send_user "Host: $RHOST\n" 69 70 # rlogin to the host 71 spawn rlogin $RHOST -l $RUSER 72 73 # Uncomment code below and add root's passwd if .rhosts file is not 74 # present on remote host. 75 #--------------------------------- 76 #set PASSWD "<ROOT PASSWORD HERE>" 77 #expect -re "Password:" 78 #send "$PASSWD\r" 79 80 # Wait for shell prompt 81 expect -re "$RUSER@" 82 83 # Run passwd command - and respond to its prompts 84 send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$RHOST \r" 85 # When shell prompt comes back, logout 86 87 expect -re "$RUSER@" 88 exp_send "logout\r" 89 90 send_user "CHECKING RLOGIN STATUS\n" 91 set nummatch [exec rsh -n -l $RUSER $RHOST "cat $TESTLOG/$RUSER.$RHOST|grep -c 9"] 92 if {$nummatch==1} { 93 send_user "$TC interactive Test Successful in LOOP $count\r" 94 exec rsh -n -l $RUSER $RHOST "rm -f $TESTLOG/$RUSER.$RHOST" 95 } else { 96 send_user "$TC interactive session FAILED\r" 97 exit 1 98 } 99} 100 101send_user "\nTest PASSES\n\n" 102exit 0 103