Use of objective CT-Modify the Linux User Password-general Linux technology-Linux programming and kernel information. For details, see the following. Expect is a tool used to control interactive programs. It is designed as a specialized tool for interacting with interactive programs. It can make up for the limitations of user interfaces provided by sh, csh and other shell in linux.
The secondary CT programmer can write scripts to describe the conversation between the program and the user, and then the secondary CT program can run the "interactive" program without interaction. Secondary CT can also be used to automate part of the conversation, because program control can be switched between the keyboard and script.
CODE :#! /Usr/bin/CT
If {$ argc <1 }{ Send_user "usage: $ argv0 U_Name PassWD \ n" Exit 1 } Set UN [lindex $ argv 0] Set PW [lindex $ argv 1]
Spawn-noecho/usr/bin/passwd $ UN CT { "Password" {send "$ PW \ n "} } CT { "Password" {send "$ PW \ n "} } CT { "Password" {send "$ PW \ n "} } CT eof Exit 0 |