#!/usr/bin/expect # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/usr/lib/nim/methods/kinit.exp 1.2 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2009 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)45 1.2 src/bos/usr/lib/nim/methods/kinit.exp, cmdnim, bos720 4/16/09 10:58:49 # # COMPONENT_NAME: CMDNIM # # FUNCTIONS: ./usr/lib/nim/methods/kinit.exp # # ORIGINS: 27 # # (C) COPYRIGHT International Business Machines Corp. 2009 # All Rights Reserved # Licensed Materials - Property of IBM # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # log_user 0 exp_internal 0 set user "" set passwd "" set program "kinit.exp" set exit_status 1 if { [info exists env(NIM_DEBUG)] } { log_user 1 exp_internal 1 } while { [llength $argv] > 0 } { set flag [lindex $argv 0] switch -glob -- $flag { "-u" { set user [lindex $argv 1] set argv [lrange $argv 2 end] } "-p" { set passwd [lindex $argv 1] set argv [lrange $argv 2 end] } "-*" { send_user 'illegal option: $flag\n' } default { break } } } if { ($user != "") && ($passwd != "") } { set timeout 30 spawn -noecho /usr/krb5/bin/kinit $user expect { -re "assword" { send "$passwd\n"; expect eof } timeout { send_user "Timeout waiting for kinit"; close } eof } set ret [exp_wait] set pid [lindex $ret 0] set spawn_id [lindex $ret 1] set os_error [lindex $ret 2] set exit_status [lindex $ret 3] if { $exit_status } { send_user "Error: $expect_out(buffer)\n" } } else { send_user "Missing argument.\n" send_user "Usage: $program -u user -p password\n" } exit $exit_status