#! /usr/bin/env expect #+ # NAME: # hammer_pwd.exp # PURPOSE: # "Expect" wrapper for single bash command for password request # CATEGORY: # caida/gen/expect # CALLING SEQUENCE: # hammer_pwd.exp pwd_file cmd # INPUTS: # Password # RESTRICTIONS: # The location of this script must be in the path # EXAMPLE: # hammer_pwd.exp pwd.txt IDL_DEV=Z; export IDL_DEV; idl -quiet -e "member_domains,/scp" # PROCEDURE: # MODIFICATION HISTORY: # SEP-2009, Paul Hick (UCSD/CAIDA) # SEP-2010, Paul Hick (UCSD/CAIDA; pphick@caida.org) # First arg is now the name of a file containing the password, # instead of the password itself. #- # set Variables set passwd_file [lrange $argv 0 0] set command [lrange $argv 1 end] set fp [open "$passwd_file" r] set passwd [read $fp] close $fp set timeout -1 puts "cmd: $command" # now connect to remote UNIX box (ipaddr) with given script to execute spawn bash --login -c "$command" match_max 100000 # Look for password prompt expect "*?assword*" # Send password aka $passwd send -- "$passwd\r" # send blank line (\r) to make sure we get back to gui send -- "\r" expect eof