stub for expectlib
This commit is contained in:
parent
b79cd589ba
commit
65b908fada
|
|
@ -0,0 +1,100 @@
|
||||||
|
#!/usr/bin/env tclsh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 Dyne.org Foundation
|
||||||
|
# libdevuansdk is written and maintained by
|
||||||
|
# Jaromil <jaromil@dyne.org>
|
||||||
|
# KatolaZ <katolaz@freaknet.org>
|
||||||
|
# parazyd <parazyd@dyne.org>
|
||||||
|
#
|
||||||
|
# This file is part of libdevuansdk
|
||||||
|
#
|
||||||
|
# This source code is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This software is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this source code. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
package require Expect
|
||||||
|
|
||||||
|
|
||||||
|
proc ssh_run_cmd_ssh {sshuser sshpass sshhost sshport cmdname args} {
|
||||||
|
|
||||||
|
set timeout 30
|
||||||
|
|
||||||
|
spawn ssh -p $sshport $sshuser@$sshhost
|
||||||
|
|
||||||
|
expect "yes/no" {
|
||||||
|
send "yes\r"
|
||||||
|
expect "*?assword" { send "$sshpass\r" }
|
||||||
|
} "*?assword" { send "$sshpass\r" }
|
||||||
|
|
||||||
|
expect "$ " { send "${cmdname} ${args}\r" }
|
||||||
|
expect "$ " { send "exit \r"}
|
||||||
|
interact
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc ssh_scpget {sshuser sshpass sshhost sshport srcfile dstfile} {
|
||||||
|
|
||||||
|
set timeout 120
|
||||||
|
|
||||||
|
spawn scp -P $sshport $sshuser@$sshhost:${scporig} $scpdest
|
||||||
|
|
||||||
|
expect "yes/no" {
|
||||||
|
send "yes\r"
|
||||||
|
expect "*?assword" { send "$sshpass\r" }
|
||||||
|
} "*?assword" { send "$sshpass\r" }
|
||||||
|
|
||||||
|
expect "100%"
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ssh_scpput {sshuser sshpass sshhost sshport srcfile dstfile} {
|
||||||
|
|
||||||
|
set timeout 120
|
||||||
|
|
||||||
|
spawn scp -P $sshport $scporig $sshuser@$sshhost:$scpdest
|
||||||
|
|
||||||
|
|
||||||
|
expect "yes/no" {
|
||||||
|
send "yes\r"
|
||||||
|
expect "*?assword" { send "$sshpass\r" }
|
||||||
|
} "*?assword" { send "$sshpass\r" }
|
||||||
|
|
||||||
|
expect "100%"
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc expectlib_call { name args } {
|
||||||
|
|
||||||
|
puts "name: $name"
|
||||||
|
puts "args: $args"
|
||||||
|
|
||||||
|
switch -- $name {
|
||||||
|
scpput {
|
||||||
|
ssh_scpput {*}$args
|
||||||
|
}
|
||||||
|
scpget {
|
||||||
|
ssh_scpget {*}$args
|
||||||
|
}
|
||||||
|
sshrun {
|
||||||
|
ssh_run_cmd_ssh {*}$args
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
set params [split $argv " "]
|
||||||
|
|
||||||
|
expectlib_call {*}$params
|
||||||
|
|
||||||
|
|
||||||
2
zuper
2
zuper
|
|
@ -1 +1 @@
|
||||||
Subproject commit 36c81fbbe63e0ced3475f1484efca19b93110698
|
Subproject commit a9b9d76b0d7efdf9ad6f5180ae447b3eabbc09d1
|
||||||
Loading…
Reference in New Issue