Is there a limit on prompt length for Telnet Shell?

0 votes
asked Apr 30, 2012 by Joel Lee (170 points)
edited Jul 16, 2014

We occasionally use a Telnet Shell to run some shell commands on an AIX box. After successfull login, we immediately change the prompt via an export PS1 command sent to the shell. We also set the shell prompt accordingly.

For example, in C# we do this:

shell.Prompt= "$XYZ$";

shell.SendCommand(@"export PS1=""$XYZ$""");

This works fine, as long as the prompt length is pretty short. That is, after executing the above, I can send commands, and get their output, and the shell is able to figure out where the end of each output is, based on the prompt string.

This has worked just fine with a number of shell commands. However, recently we attempted to execute a copy command (e.g. cp somefile1 somefile2), and the command consistently fails unless the prompt is10 characters or less. So, for example ":PROMPTXY:" will work, but ":PROMPTXYZ:" will not. Some other commands that we have tried do not seem to care (e.g. ls -l). The only difference we could see was that the copy command does not normally return any output to the shell.

An error occurs when we attempt to send the copy command to the shell (via shell.SendCommand(...)). The exeception thrown by Rebex says "Unable to process command", which I am guessing means there was a problem synchronizing on the prompt.

Any ideas what is going on here?

3 Answers

0 votes
answered May 3, 2012 by Lukas Matyska (61,230 points)
edited Mar 20, 2013
Best answer

There is no limit on prompt length. Can you please send us the session log in Verbose level to for detailed investigation of the issue?

It can be produced as shown bellow.
Please note it can contain sensitive data, so I suggest you to assign the LogWriter property just after the login sequence, or edit the log file manually.

// start shell
Telnet client = new Telnet("host");
Shell shell = client.StartShell();
shell.Prompt = "prompt";

// log in
shell.ReadAll(": ");
shell.ReadAll(": ");

// assign logger
client.LogWriter = new Rebex.FileLogWriter("C:/temp/telnet.log", LogLevel.Verbose);

// read welcome message

// do some work
commented May 3, 2012 by Joel Lee (170 points)
edited May 3, 2012

Thanks for your reply. I will get a verbose log for you, but it will probably take a couple of days to get around to it.

commented May 3, 2012 by Lukas Matyska (61,230 points)
edited Jul 12, 2012

Thanks, it is not a problem for us.

Actually, there is one alternative to the Shell class you may be interested in. Please try to use the VirtualShell class which is a helper class wrapping the VirtualTerminal class. Download

Instead of Shell shell = client.StartShell() call VirtualShell shell = new VirtualShell(client.StartVirtualTerminal())

commented May 22, 2012 by Joel Lee (170 points)
edited May 22, 2012

I'm going to accept this as the answer to my question about limit on prompt length. That is, there is no limit. We are still having issues with prompt length, and also if we try to send a command that is "too long". We think it has something to do with the terminal type, so I will try the Virtual Terminal and see if that works for us. If it does, I will post a comment here to confirm.

commented May 23, 2012 by Lukas Matyska (61,230 points)
edited May 23, 2012

Thank you, posting a comment is appreciated.

Please note, that terminal type can be specified using the TerminalOptions.TerminalName property. However terminal type is negotiated just after the connection is established, so you have to set the property before you start the VirtualTerminal. It can be done as follows:

TerminalOptions options = new TerminalOptions();
options.TerminalName = "vt100";

Telnet client = new Telnet("server");
VirtualTerminal vt = client.StartVirtualTerminal(options, 80, 25);
0 votes
answered Mar 20, 2013 by thorst (160 points)
edited Mar 20, 2013

I ran into this issue as well.

When calling the below it seems to not like more than 74 characters


However, if you change the line to the below, i havent found the limit

commented Mar 20, 2013 by Lukas Matyska (61,230 points)
edited Mar 20, 2013

Can you please send us the Verbose log as shown above? Please email it to

0 votes
answered Jul 16, 2014 by Pavel Matyska (15,060 points)
edited Jul 16, 2014

Hi, we have just release new Scripting API in 2014-R2 release. You can read more of its features on Scripting features page.