- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: expect problems changing password
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
03-25-2004 07:53 AM
03-25-2004 07:53 AM
reset_password() {
UNAME=$LoginID
UPASS=$NEWPASS
/usr/local/bin/expect -d <
match_max 100000
spawn passwd $UNAME\r
expect -exact "Changing password for testuser\r
New password: "
send "$UPASS\r"
expect "Re-enter new password:"
send "$UPASS\r"
send "exit\r"
EOF
return $?
}
I am getting this output from the expect debugger:
expect version 5.39.0
argv[0] = /usr/local/bin/expect argv[1] = -d
set argc 0
set argv0 "/usr/local/bin/expect"
set argv ""
executing commands from command file
spawn passwd testuser
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {26705}
expect: does "" (spawn_id exp6) match exact string "Changing password for testuser\r\nNew password: "? no
Invalid login name.
expect: does "Invalid login name.\r\n" (spawn_id exp6) match exact string "Changing password for testuser\r\nNew password: "? no
expect: read eof
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "Invalid login name.\r\n"
send: sending "test123\r" to { exp6 send: spawn id exp6 not open
while executing
"send "test123\r""
Looks like either a timing problem or a problem with too many or too few control characters on the "spawn" line. Can anyone tell me what to fix?
TIA
mark
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2004 12:16 AM
03-26-2004 12:16 AM
Re: expect problems changing password
The user ID "testuser" does exist, and I can change the password for that ID interactively via sam or the commandline.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2004 12:47 AM
03-26-2004 12:47 AM
SolutionHi Mark, i don't know expect, but in shell script sometimes the variable name needs braces around it.
For example:
the line
spawn passwd $UNAME\r will be:
spawn passwd ${UNAME}\r
and perhaps \n instead of \r
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2004 01:04 AM
03-26-2004 01:04 AM
Re: expect problems changing password
You should just need to use
spawn passwd $UNAME
(we use expect with some scripts via telnet using "spawn telnet $SERVER")
the "\r" is seen as a carriage return when using echo and a few other commands, but even then, it needs to be surrounded by quotes to be interpreted correctly.
You can see this behaviour using
echo "\r"
and
echo \r
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2004 01:26 AM
03-26-2004 01:26 AM
Re: expect problems changing password
mark