Our vBulletin migration is complete.
Welcome vBulletin users! All content and user information from the Micro Focus Forums (vBulletin) site has been migrated to this site. READ MORE.
garecanbp Super Contributor.
Super Contributor.
621 views

.net script Telnet Not Recognized

Hi there,

i have strange issue,

I create .net script to call cmd using ConsoleWindow and so far I get no problem until I try telnet

this is my code

ConsoleWindow.TypeKeys("telnet 192.168.204.1 21<ENTER>")

and I got error

'telnet' is not recognized as an internal or external command, operable program or batch file.

Strangely if I manually (run new cmd) telnet, it passed, only when running from silk test i got this error.

Anyone please suggest me about this issue.

0 Likes
8 Replies
Micro Focus Expert
Micro Focus Expert

RE: .net script Telnet Not Recognized

Hi,

I can only assume that there is a difference between the command prompt sessions.

Is Silk Test invoke a 32bit or 64bit version of command prompt (cmd.exe)?

I suspect that Silk Test is invoking a 32bit cmd window and telnet is installed as a 64bit process and not available in a 32bit cmd window. Therefore, when you attempt to perform a telnet, the command is not recognized.

You may need to modify your test/script to explicitly invoke the 64bit version of cmd.exe.

-Robert
0 Likes
garecanbp Super Contributor.
Super Contributor.

RE: .net script Telnet Not Recognized

"You may need to modify your test/script to explicitly invoke the 64bit version of cmd.exe."

Update: cmd from Silk Test 32bit and manual 64bit

How do we set Class ConsoleWindow to invoke 64 bit version of cmd?

0 Likes
JohnLy Absent Member.
Absent Member.

RE: .net script Telnet Not Recognized

Hi,

In addition Roberts advice, you will also need to ensure that Telnet is installed on the machine.

To install, you have to go to Control Panel>Programs>Turn Windows features on or off. Then, check "Telnet Client" and save the changes. You might have to wait about a few minutes before the change could take effect.

Thanks,
John
0 Likes
garecanbp Super Contributor.
Super Contributor.

RE: .net script Telnet Not Recognized

Thanks John,
I ensure that Telnet Client is already installed on the machine.
Now I am looking for a way to invoke 64bit cmd from ConsoleWindow or other class if any
0 Likes
garecanbp Super Contributor.
Super Contributor.

RE: .net script Telnet Not Recognized

anyone have idea for this?
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: .net script Telnet Not Recognized

If you are using Silk Test 18.5 or later, then in Workbench you can utilise the SystemFunctions functionality to execute command line directly using the Execute() method. You can encapsulate the result within the ExecutionResult and return this as a string with the ExecutionResult.Output() method.

For example:

Dim eReturn As SystemFunctions.ExecutionResult
eReturn = Agent.SystemFunctions.Execute("telnet 192.168.204.121")
Console.WriteLine(eReturn.Output())

Does this help?
0 Likes
garecanbp Super Contributor.
Super Contributor.

RE: .net script Telnet Not Recognized

Thanks Colin,
I tried the code and get error when compiling
"Argument not specified for parameter 'executionMode' of 'Public Function Execute ..."
on line eReturn = Agent.SystemFunctions.Execute("telnet 192.168.204.121")
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: .net script Telnet Not Recognized

Hi,

If you only need to open a telnet session, Colin's solution should suffice.

If after opening the telnet session, you need to execute additional commands, you will need to open a command prompt terminal. To launch a 64bit command prompt terminal, we can just create a BaseState object to launch the 64bit cmd terminal:

 

     Try
          Agent.SetOption(Options.ApplicationReadyTimeout, 1000)
          Dim cmd64 As New BaseState("c:\Windows\System32\cmd.exe", "/*")
          cmd64.Execute()

          Agent.SetOption(Options.ApplicationReadyTimeout, 30000)
     Catch ex As Exception
          '
     End Try

 

Please ensure that "Catch Exceptions when Thrown" playback setting is set to "No".

Regards
Robert

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.