SendCommand length greater than 80

0 votes
asked Jun 5, 2012 by Brad_Kremer (190 points)
edited Jul 16, 2014

I'm connecting to an embedded unix target running BusyBox.

Here is my Shell config:

m_shell = m_ssh.StartShell(ShellMode.Prompt);
m_shell.Prompt = "regex:([$])|([#]) ";
m_shell.Encoding = Encoding.UTF8;
m_shell.Timeout = timeout;

m_shell.SendCommand(command);
response = m_shell.ReadAll();

If Issue the following two command to SendCommand:

echo "1234567890123456789012345678901234567890123456789012345678" > /tmp/test1
echo "123456789012345678901234567890123456789012345678901234567890" > /tmp/test2

The first command completes successfully.
The second command throws an Rebex.TerminalEmulation.TerminalException with a status of TerminalExceptionStatus.OperationFailure.

The command actually completes correctly, and the file is created.

How can I change the command length to be greater than 80 characters?

2 Answers

0 votes
answered Jun 6, 2012 by Lukas Matyska (40,360 points)
edited Jul 12, 2012

The maximal command length cannot be changed in the Shell. Please use our experimental advanced class VirtualShell. You can use it as follows:

// declare VirtualShell instead of the Shell
VirtualShell m_shell;

// initialize shell by the VirtualTerminal
m_shell = new VirtualShell(m_ssh.StartVirtualTerminal());

m_shell.Prompt = "([$]|[#]) ";
m_shell.Terminal.Options.Encoding = Encoding.UTF8;
m_shell.Timeout = timeout;

m_shell.SendCommand(command);
response = m_shell.ReadAll();
commented Jun 6, 2012 by Brad_Kremer (190 points)
edited Jun 6, 2012

It behaves totally different than the standard Shell. It is more interactive. I would like it if it just didn't throw an exception when the command length is > 80.

commented Jun 7, 2012 by Lukas Matyska (40,360 points)
edited Jun 7, 2012

Please note, that StartShell(ShellMode.Prompt) uses a virtual terminal internally, which means the interactivity is there as well, although it is masked by the Shell API (which turned out not to be a good thing in many cases - for example, screen width is fixed to 80 characters).

If the VirtualTerminal is too interactive for you, please try to call StartShell(ShellMode.WellKnownShell).

commented Jun 8, 2012 by Brad_Kremer (190 points)
edited Jun 8, 2012

WellKnownShell caused problems with standard out/error order. See my other post. http://forum.rebex.net/questions/2387/sendcommand-readall-and-standard-out-error

commented Jun 11, 2012 by Lukas Matyska (40,360 points)
edited Jun 11, 2012

Using the VirtualShell class is desired solution. Can you please tell us, why the class is not suitable for you? We can improve it to fulfill your needs.

commented Jun 12, 2012 by Lukas Matyska (40,360 points)
edited Jun 12, 2012

Alternatively, you can try to send the command as a password: m_shell.SendCommand(command, true);

Does it help?

0 votes
answered Jul 16, 2014 by Pavel Matyska (9,740 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.

...