在使用expect时使用命令行参数(using command line argument while using expect)

编程入门 行业动态 更新时间:2024-10-17 02:54:59
在使用expect时使用命令行参数(using command line argument while using expect)

您好我正在使用期望将文件输入到远程计算机。我将文件名作为命令行参数传递给脚本。但错误是从行中抛出

send -- "mput $1\r"

我的代码如下:

set timeout 1000 spawn ftp $ipaddress expect "Name " send -- "$username\r" expect "Password" send -- "$passwd\r" expect "ftp>" send -- "mput $1\r"//error thrown from this line expect "mput $1? " send -- "y\r" expect "ftp>" send -- "bye\r"

任何人都可以请建议这里有什么问题吗?

Hi I am using expect to mput a file to a remote machine.I am passing the filename as a command line argument to the script.But error is throwing from the line

send -- "mput $1\r"

My code is as follows:

set timeout 1000 spawn ftp $ipaddress expect "Name " send -- "$username\r" expect "Password" send -- "$passwd\r" expect "ftp>" send -- "mput $1\r"//error thrown from this line expect "mput $1? " send -- "y\r" expect "ftp>" send -- "bye\r"

Could anyone please suggest what is wrong here?

最满意答案

用[lindex $argv 0]替换$1 。 $argc变量告诉给定参数的数量。

Replace $1 with [lindex $argv 0]. The $argc variable tells the number of given arguments.

更多推荐

本文发布于:2023-04-28 04:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329735.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令行   参数   expect   argument   line

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!