相当于 bash “expect"在 PowerShell 中 [英] Equivalent to bash "expect" in powershell

查看:226
本文介绍了相当于 bash “expect"在 PowerShell 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 powershell 运行另一个 powershell 脚本,在某些时候,另一个脚本需要一些输入,我希望能够读取另一个脚本的输出并基于该脚本的输入.类似于您可以在 bash 上使用 expect 执行的操作.

I'm using powershell to run another powershell script, at some point the other script asks for some input, I would like to be able to read the output from the other script and based on that supply input to it. Similar to what you can do with expect on bash.

有什么想法吗?

谢谢

推荐答案

只是发布我的解决方案,以便它可以帮助某人.我在运行其他一些需要答案的脚本时遇到了同样的问题.首先创建一个文件inputFileLocation.txt",按顺序在每一行中包含每个问题的答案.然后以下面的语法运行脚本.它会完成工作.

Just posting my solution so that it can help someone. I faced the same problem while running some other script that will ask for answers. First create a file "inputFileLocation.txt" with answers to each question in each line in sequence. Then run the script in below syntax. And it will do the work.

`cmd.exe /c "script.bat < inputFileLocation.txt"`

这篇关于相当于 bash “expect"在 PowerShell 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆