最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

automation - Powershell 7 - Extra characters after close-brace - Stack Overflow

programmeradmin5浏览0评论

I am extremely new to Powershell. I am trying to learn by writing an automation script that sshs into a device and runs some commands. Since the remote device is using Ubuntu 20 and I am not allowed to use ssh keys, I am having to implement expect statements.

I have installed Cygwin to get access to the expect command and ensured that the correct environment path has been added to my Windows laptop.

The problem is in this line of code:

$session = @"
spawn ssh -tt $user@$ip_address
expect {
     -re ".*password: " {
         send "$pword\r"
}
}
"@

The error that I am receiving looks like it shows a s" in the output:

extra characters after the close-brace
 while executing
"expect {
 -re ".*password: " {
         send "$pword\r"
}
}s"

Is there a reason why that s" is showing up? Is that what is causing my issues? Thank you for the help!

发布评论

评论列表(0)

  1. 暂无评论