shell向expect传参 , shell向expect传递变量

您所在的位置:网站首页 Linux启动脚本怎么传参数 shell向expect传参 , shell向expect传递变量

shell向expect传参 , shell向expect传递变量

2023-11-24 05:22| 来源: 网络整理| 查看: 265

原文地址::https://blog.csdn.net/qq_34354426/article/details/79892336

相关文章

1、如何向expect脚本里面传递参数----https://zhidao.baidu.com/question/988132621798573699.html?qbl=relate_question_2&word=shell%BD%C5%B1%BEexpect%C4%DC%B4%AB%B2%CE%CA%FD%B2%BB

2、linux-如何在shell脚本中通过命令行传递expect参数----https://www.itranslater.com/qa/details/2582476486389269504

两个脚本:  

  startupload.sh 

  uploadmac.exp

 

startupload.sh  向 uploadmac.exp 中传入参数

 

startupload.sh :

#!/bin/bash

ip="10.122.112.112"

name="jack"

./uploadmac.exp $ip $name [/bash]  

uploadmac.exp: 

sset ip [lrange $argv 0 0]

 set name [lrange $argv 1 1]

spawn scp /home/cs/sss.mp3 $name@$ip:~/yuneecapp-ios/ set timeout 20 expect { "yes/no" {send "yes\r";exp_continue} "Password:" {send "123456\r"} } send "123456\r" expect eof

 

 

 

//================================================================================

//本人备注::

1)编写脚本 #!/usr/bin/expect set ip [lindex $argv 0] set username [lindex $argv 1] set passwd [lindex $argv 2] spawn ssh -l $username $ip expect { "yes/no" { send "yes\r";exp_continue } "password:" { send "$passwd\r" } } #expect eof interact



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3