libdevuansdk

common library for devuan's simple distro kits
git clone https://git.parazyd.org/libdevuansdk
Log | Files | Refs | Submodules | README | LICENSE

commit 65b908fada6237c8b917fd5a22f3464637ae34cb
parent b79cd589ba01aa570ff4ff8dd8268f0d95c7f89f
Author: KatolaZ <katolaz@freaknet.org>
Date:   Wed, 15 Jun 2016 07:12:02 +0100

stub for expectlib

Diffstat:
Azlibs/expectlib | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+), 0 deletions(-)

diff --git a/zlibs/expectlib b/zlibs/expectlib @@ -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 + +