Perl Expect fails to trigger the Ssh File Server ShellCommand event

0 votes
asked May 7 by walljm (470 points)

We're using a perl expect library to interact with a custom File Server that listens for certain commands and returns output on the cli.

The perl expect library, for some reason, once it connects and sends the password, successfully identifies the prompt, it sends a command but that command is never recieved by the FileServer.ShellCommand event. I'm at a loss as to why. This expect code works fine when connecting to other ssh cli's.

Any help would be appreciated.

1 Answer

0 votes
answered May 7 by walljm (470 points)
selected May 7 by Lukas Pokorny
 
Best answer

ok. figured it out. i believe this is bug in Rebex.

The ProcessBase.cs file, line 538 it handles the \r but doesn't handle \n as a line break so it fails to detect the command as entered and doesn't write the line.

the addition of a case '\n': below the case '\r': fixes it.

                case '\r':
                case '\n':
                    WriteLine();
                    command = _command.ToString().TrimEnd();
                    _command.Length = 0;
                    _position = 0;

                    if (command.Length > 0)
                        AddToHistory(command);

                    return command;
commented May 7 by Lukas Pokorny (108,330 points)
Thanks for reporting this, and kudos for figuring out the reason!

Apparently, common SSH servers accept both \r and \n, so we'll modify our behavior accordingly as well in the next release. (We will use a slightly different approach that would also work fine with SSH clients that send both \r\n in addition to \r or \n alone.)
commented May 7 by walljm (470 points)
Thanks!  Is there a way I can be notified when this is released?
commented May 7 by Lukas Pokorny (108,330 points)
We'll post a notice here, so if you have notifications turned on, it should reach you.
Or subscribe to our newsletter to make sure you don't miss a new release: https://rebex.us5.list-manage.com/subscribe?u=6e0e34c882602d1cf12bc584b&id=e7c9ad3959
commented May 26 by Lukas Pokorny (108,330 points)
This has been fixed in our latest release, 2020 R2. We'll also be sending the newsletter soon.
...