# perl tester-a.pl
Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, 'ARRAY(0x1a317770)', 'ARRAY(0x1a3177c0)') called at tester-a.pl line 32
main::change_password('solarishost') called at tester-a.pl line 20
Password: Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, '$') called at tester-a.pl line 48
main::change_password('solarishost') called at tester-a.pl line 20
Last login: Wed Apr 8 10:32:54 2015 from mycomputer.
$ Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, 'Password:') called at tester-a.pl line 50
main::change_password('solarishost') called at tester-a.pl line 20
su - root
Password: Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, '#') called at tester-a.pl line 52
main::change_password('solarishost') called at tester-a.pl line 20
[root@solarishost ~ ] # Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, '#') called at tester-a.pl line 54
main::change_password('solarishost') called at tester-a.pl line 20
hostname
solarishost
[root@solarishost ~ ] # Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, '#') called at tester-a.pl line 56
main::change_password('solarishost') called at tester-a.pl line 20
uptime
1:59pm up 10 day(s), 14:43, 4 users, load average: 5.19, 5.16, 4.90
[root@solarishost ~ ] # Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, 'New Password:') called at tester-a.pl line 58
main::change_password('solarishost') called at tester-a.pl line 20
passwd amagana
New Password: Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, 'Re-enter new Password:') called at tester-a.pl line 60
main::change_password('solarishost') called at tester-a.pl line 20
Re-enter new Password: Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, '#') called at tester-a.pl line 62
main::change_password('solarishost') called at tester-a.pl line 20
passwd: password successfully changed for amagana
[root@solarishost ~ ] # Starting EXPECT pattern matching...
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561
Expect::expect('Expect=GLOB(0x1a317160)', 60, '$') called at tester-a.pl line 64
main::change_password('solarishost') called at tester-a.pl line 20
exit
logout
$ Closing spawn id(3).
at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 1431
Expect::hard_close('Expect=GLOB(0x1a317160)') called at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 1621
Expect::DESTROY('Expect=GLOB(0x1a317160)') called at tester-a.pl line 20
eval {...} called at tester-a.pl line 20
main::change_password('solarishost') called at tester-a.pl line 20
Pid 4754 of spawn id(3) terminated, Status: 0xFF00
####
vi /var/tmp/expect_script.log
======= system =======
^M
You are accessing a U.S. Government (USG) Information System (IS) that is ^M
provided for USG-authorized use only. ^M
^M
By using this IS (which includes any device attached to this IS), you consent^M
to the following conditions: ^M
^M
-The USG routinely intercepts and monitors communications on this IS for ^M
purposes including, but not limited to, penetration testing, COMSEC ^M
monitoring, network operations and defense, personnel misconduct (PM), law ^M
enforcement (LE), and counterintelligence (CI) investigations. ^M
^M
-At any time, the USG may inspect and seize data stored on this IS. ^M
^M
-Communications using, or data stored on, this IS are not private, are ^M
subject to routine monitoring, interception, and search, and may be ^M
disclosed or used for any USG authorized purpose. ^M
^M
-This IS includes security measures (e.g.,authentication and access controls)^M
to protect USG interests--not for your personal benefit or privacy. ^M
^M
-Notwithstanding the above, using this IS does not constitute consent to PM, ^M
LE or CI investigative searching or monitoring of the content of privileged ^M
communications, or work product, related to personal representation or ^M
services by attorneys, psychotherapists, or clergy, and their assistants. ^M
Such communications and work product are private and confidential.^M
Password: ^M
Last login: Wed Apr 8 10:32:54 2015 from mycomputer.^M^M
+-----------------------------------------------------------------------------+^M
|You are accessing a U.S. Government (USG) Information System (IS) that is |^M
|provided for USG-authorized use only. |^M
| |^M
|By using this IS (which includes any device attached to this IS), you consent|^M
|to the following conditions: |^M
| |^M
|-The USG routinely intercepts and monitors communications on this IS for |^M
| purposes including, but not limited to, penetration testing, COMSEC |^M
| monitoring, network operations and defense, personnel misconduct (PM), law |^M
| enforcement (LE), and counterintelligence (CI) investigations. |^M
| |^M
|-At any time, the USG may inspect and seize data stored on this IS. |^M
| |^M
|-Communications using, or data stored on, this IS are not private, are |^M
| subject to routine monitoring, interception, and search, and may be |^M
| disclosed or used for any USG authorized purpose. |^M
| |^M
|-This IS includes security measures (e.g.,authentication and access controls)|^M
| to protect USG interests--not for your personal benefit or privacy. |^M
| |^M
|-Notwithstanding the above, using this IS does not constitute consent to PM, |^M
| LE or CI investigative searching or monitoring of the content of privileged |^M
| communications, or work product, related to personal representation or |^M
| services by attorneys, psychotherapists, or clergy, and their assistants. |^M
| Such communications and work product are private and confidential. |^M
+-----------------------------------------------------------------------------+^M
$ su - root^M
Password: ^M
+-----------------------------------------------------------------------------+^M
|You are accessing a U.S. Government (USG) Information System (IS) that is |^M
|provided for USG-authorized use only. |^M
| |^M
|By using this IS (which includes any device attached to this IS), you consent|^M
|to the following conditions: |^M
| |^M
|-The USG routinely intercepts and monitors communications on this IS for |^M
| purposes including, but not limited to, penetration testing, COMSEC |^M
| monitoring, network operations and defense, personnel misconduct (PM), law |^M
| enforcement (LE), and counterintelligence (CI) investigations. |^M
| |^M
|-At any time, the USG may inspect and seize data stored on this IS. |^M
| |^M
|-Communications using, or data stored on, this IS are not private, are |^M
| subject to routine monitoring, interception, and search, and may be |^M
| disclosed or used for any USG authorized purpose. |^M
| |^M
|-This IS includes security measures (e.g.,authentication and access controls)|^M
| to protect USG interests--not for your personal benefit or privacy. |^M
| |^M
|-Notwithstanding the above, using this IS does not constitute consent to PM, |^M
| LE or CI investigative searching or monitoring of the content of privileged |^M
| communications, or work product, related to personal representation or |^M
| services by attorneys, psychotherapists, or clergy, and their assistants. |^M
| Such communications and work product are private and confidential. |^M
+-----------------------------------------------------------------------------+^M
^[[01m[root@solarishost ~ ]^[[m # hostname^M
solarishost^M
^[[01m[root@solarishost ~ ]^[[m # uptime^M
1:59pm up 10 day(s), 14:43, 4 users, load average: 5.19, 5.16, 4.90^M
^[[01m[root@solarishost ~ ]^[[m # passwd amagana^M
New Password: ^M
Re-enter new Password: ^M
passwd: password successfully changed for amagana^M
^[[01m[root@solarishost ~ ]^[[m # exit^M
logout^M
$