I'm trying to run a Powershell script that will call a batch script that will start a telnet session and run the following command:
mediaGet("gei",1)
Thanks to this stackoverflow question Is it possible to use a batch file to establish a telnet session, send a command and have the output written to a file? I have written two scripts:
telnet.bat
start telnet.exe 162.100.10.10
cscript telnet.vbs
telnet.vbs
set OBJECT=WScript.CreateObject("WScript.Shell")
Dim cmd
cmd = "mediaGet("gei",1)
WScript.sleep 50
OBJECT.SendKeys cmd
WScript.sleep 50
OBJECT.SendKeys "{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "exit{ENTER}"
WScript.sleep 5000
OBJECT.SendKeys " "
However, when I run the scripts, the vbs script cannot read the string of the variable cmd. So I changed it as such:
cmd = "mediaGet" & chr(40) & chr(34) & "gei" & ",1" & chr(41)
But still, it outputs it on the telnet terminal as such:
mediaGet"gei",1
How can I make it read the parenthesis in the string variable? If the scripts end up working, does anyone know how to save the output of the vbs script into a log file?