3 set pwfile "/etc/openvpn/pass.txt"
5 # minimalistic argument parsing, only assumtion is that the first one will be the hostname
7 set host [lindex $argv 0]
9 } elseif { $argc > 1 } {
10 set host [lindex $argv 0]
11 set sshargs [lrange $argv 1 end]
13 puts "Error no hostname given"
14 puts "$argv0 hostname \[other ssh arguments\]"
18 # extract username and password from an OpenVPN password file
19 # assumption is that the first line holds the username, the second the password
20 proc read_pwfile { pwfile } {
22 set pwf [open $pwfile r]
26 set pwlines [split $pwdat "\n"]
27 set user [lindex $pwlines 0]
28 set pass [lindex $pwlines 1]
34 # assemble the spawn command we plan to execute
35 if { [string length $sshargs] == 0 } {
36 set spawncmd "spawn ssh -l $user $host"
38 set spawncmd "spawn ssh -l $user $sshargs $host"
41 puts "Connecting with user $user to hosts $host with args $sshargs"
43 expect -re ".*assword:"