I am running a Powershell script that starts a telnet process which will connect on a client machine and run a command. The client machine's operating system is a personalized version of VxWorks, and the command I'm using on the telnet calls a tool developed internally on the machine:
mediaGet("gei",1)
I'd like to retrieve the output of the code and log it.
I've tried using the parameters -NoNewWindow and -RedirectStandardOutput on the Powershell script, but it only creates me an empty file which means it fails to retrieve the output.
Here is the Powershell script:
Start-Process -FilePath 'telnet.exe' -ArgumentList '162.100.10.10'
[system.reflection.assembly]::loadwithpartialname("System.Windows.Forms")
$SendKeys = [System.Windows.Forms.SendKeys]
$sendkeys::SendWait('mediaGet{(}"gei"{)},1')
Start-Sleep -Seconds .5
$sendkeys::SendWait("{ENTER}")
Start-Sleep -Seconds .5
$sendkeys::SendWait("exit{ENTER}")
(Credits of this code go to the selected answer of this question How to use a string variable as a telnet command in a vbscript?)
This is the output of the code
mediaGet("gei",1)
> media: 12345
> up: 1000 full duplex
I would like a text file at the end with the following lines:
media: 12345
up: 1000 full duplex
How can I get there?