0 votes
by (190 points)
edited

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
by (73.5k points)
edited

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();
by (190 points)
edited

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.

by (73.5k points)
edited

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).

by (190 points)
edited

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

by (73.5k points)
edited

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.

by (73.5k points)
edited

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

Does it help?

0 votes
by (15.2k points)
edited

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

...