|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Infrastructure Monitoring Forum for Nagios, Zabbix and other network monitoring and management tools. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#15
|
||||
|
||||
|
Do you have ksh available?
|
|
#16
|
|||
|
|||
|
Doing this install , you need "root" rights , i'm onlu user !!
christian |
|
#17
|
|||
|
|||
|
Yes i have "ksh"
christian |
|
#18
|
||||
|
||||
|
OK, when I have some time I'll experiment with ksh. I think I might be able to use a telnet coprocess to allocate the pty.
|
|
#19
|
||||
|
||||
|
No money back guarantees on this one. But I tested it on both HP-UX and SunOS and it works for me. Code:
#! /usr/bin/ksh
# changepass --- change the user's password on a list of hosts
# perderabo 9/23/03 Version 0.0
#
# You will need to adjust HOSTLIST. You may need to adjust DELAY
# and all of section 2.
#
#
# Section 0 --- Set stuff up
HOSTLIST="test1 test2"
DELAY=3
stty -echo
print -n Enter Old Password-
read OLDPASS
print
print -n Enter New Password-
read NEWPASS
print
stty echo
USER=$(whoami)
exec 4>&1
#
# Section 1 --- Prove that we can talk with the hosts in HOSTLIST
# Part 1 --- telnet to each and touch a file
for HOST in $HOSTLIST ; do
telnet $HOST >&4 2>&4 |&
sleep $DELAY
print -p $USER
sleep $DELAY
print -p $OLDPASS
sleep $DELAY
print -p touch changepassdatafile.$HOST
sleep $DELAY
print -p exit
wait
done
#
# Section 1 --- Prove that we can talk with the hosts in HOSTLIST
# Part 2 --- Retrieve the files via ftp
ftp -nv >&4 2>&4 |&
for HOST in $HOSTLIST ; do
print -p open $HOST
print -p user $USER $OLDPASS
print -p get changepassdatafile.${HOST}
print -p close
done
print -p bye
wait
#
# Section 1 --- Prove that we can talk with the hosts in HOSTLIST
# Part 3 --- Inspect the retrieved files
errors=0
for HOST in $HOSTLIST ; do
if [[ -f changepassdatafile.${HOST} ]] ; then
echo $HOST was ok
rm changepassdatafile.${HOST}
else
echo $HOST has a problem
((errors=errors+1))
fi
done
((errors)) && exit 1
#
# Section 2 --- Change the passwords
for HOST in $HOSTLIST ; do
telnet $HOST >&4 2>&4 |&
sleep $DELAY
print -p $USER
sleep $DELAY
print -p $OLDPASS
sleep $DELAY
print -p passwd
sleep $DELAY
print -p $OLDPASS
sleep $DELAY
print -p $NEWPASS
sleep $DELAY
print -p $NEWPASS
sleep $DELAY
print -p exit
wait
done
#
# Section 3 --- Verify that the passwords were changed
# Part 1 --- Retrieve those files via ftp again
ftp -nv >&4 2>&4 |&
for HOST in $HOSTLIST ; do
print -p open $HOST
print -p user $USER $NEWPASS
print -p get changepassdatafile.${HOST}
print -p delete changepassdatafile.${HOST}
print -p close
done
print -p bye
wait
#
# Section 3 --- Verify that the passwords were changed
# Part 2 --- Inspect the retrieved files
errors=0
for HOST in $HOSTLIST ; do
if [[ -f changepassdatafile.${HOST} ]] ; then
rm changepassdatafile.${HOST}
else
echo $HOST has a problem!
((errors=errors+1))
fi
done
((errors)) && exit 1
exit 0 |
|
#20
|
|||
|
|||
|
Thanks for your help ,
i will test this script as soon as possible and tell you in return ! christian |
|
#21
|
||||
|
||||
|
Real great work Perderabo !!!
This is the kind of script I like to keep a copy of ![]() Thanks a lot for all the work. I don't understand the 4> yet, but I'll probably find out somewhere. Regs David |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with expect script | somedude | Shell Programming and Scripting | 4 | 06-04-2009 12:39 PM |
| Need Help with EXPECT script | markus2008 | UNIX for Advanced & Expert Users | 5 | 03-12-2008 07:49 PM |
| help with 'expect' script? | maeve | Shell Programming and Scripting | 0 | 06-02-2004 06:18 PM |
| Expect Script HELP | zuinc | Shell Programming and Scripting | 2 | 04-30-2002 09:42 AM |
| 'expect' tool | shaggy | UNIX for Dummies Questions & Answers | 2 | 09-27-2001 02:54 PM |
|
|