- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Expect script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 12:35 PM
07-17-2003 12:35 PM
Expect script help
Here's my scripts
set password [exec cat /tmp/passwords]
set id [exec cat /tmp/id ]
foreach user $id {
spawn passwd $user
expect "New password:"
send "$password\r"
expect "Re-enter new password:"
send "$password\r"
expect "Passwd successfully changed"
}
Thanks in advance!
Christine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 02:46 PM
07-17-2003 02:46 PM
Re: Expect script help
given the lack of error checking, probably the quickest way of achiving this is by adding
lreplace $password 0 0 at the end of your loop.
this will remove the first element from the list.
.
.
.
send "$password\r"
expect "Passwd successfully changed"
lreplace $password 0 0
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2003 05:05 AM
07-18-2003 05:05 AM
Re: Expect script help
Christine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2003 05:11 AM
07-18-2003 05:11 AM
Re: Expect script help
...
expect "New password:"
send "$password$id\r"
expect "Re-enter new password:"
send "$password$id\r"
....
This ways the password will become $password$id which will be unique for that user.
Regards,
Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2003 06:32 AM
07-18-2003 06:32 AM
Re: Expect script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2003 06:42 PM
07-18-2003 06:42 PM
Re: Expect script help
paste -d " " file1 file2 > file3
this will create one file with a single space between the fields
then for your expect script
if {$argc == 0 || $argc > 1} {
send_user "Usage: [file tail $argv0] filename\n"
exit
}
set infile [lindex $argv 0]
if {[file readable $infile] == 0} {
send_user "*** error: cannot read name file \"$infile\", exit\n"
exit
}
while { [gets $infile line] != 1) {
set idpwd [split $line "\ "]
set id [lindex $idpwd 0]
set pwd [lindex $idpwd 1]
send_user "id = $id, passwd = $pwd\n"
}
in the split there is a blank (space) after the \.
this should print each user id and password as it goes through the loop. This way you can make sure the id and password is changing for each iteration. Then you can easily add your code to change the user's password.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2003 10:53 PM
07-18-2003 10:53 PM
Re: Expect script help
Make $password 5 or less characters then add the user id to it ...
-Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2003 02:30 PM
07-19-2003 02:30 PM
Re: Expect script help
while { [gets $infile line] != 1) {
the 1 should be a -1 or
while { [gets $infile line] != -1) {