You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Vishwanath Hawargi <vh...@gmail.com> on 2012/01/31 20:33:15 UTC

how to bind ShellFactory and CommandFactory?

Hi,
I am new to Apache SSHD, so apologies for the dumb questions.

I am using the standard set of calls to setup the server, port and the
factories before starting the server.

My requirement is to allow a user to login to a shell, type a command (not
scp commands, but my set of commands) (echoing what he types) and when he
hits enter,i would like the command to be executed and the output to be
dispalyed in the shell.  I have the code to handle the commands, but I am
not able to get an interactive shell.
(Also, i am on Windows XP; passing "cmd" in shellFactory gives me a dumb
and deaf shell :) where nothing happens...)

please help, i am sure i am making some silly basic mistakes.

thank you.

Re: how to bind ShellFactory and CommandFactory?

Posted by Vishwanath Hawargi <vh...@gmail.com>.
Thanks for the tip. (sorry for the late response... Kind of took vacation
for sometime!)

With these TTY options i could get nice interactive shell. thanks again
However, i am still struggling to attach the command processor. whatever i
type is consumed by the Shell, but nothing seems to reach the command
processor (i have created a command factory and a command class just like
the scp test example)

Is there somethig that i need to tweak? in/out streams all seem to be
exactly the same as they are in the other test/example codes.


thanks,
vishwa

On Wed, Feb 1, 2012 at 10:36 AM, Nilesh Apte <ni...@gmail.com>wrote:

> Hi Vishwanath:
>
> following lines from "SshServer.java" (main method) seems to be working
> for a default OS shell.
> When I run the server on WinXP and it launches cmd.exe successfully and I
> can run default commands.
> -------------
> if (OsUtils.isUNIX()) {
>     sshd.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh",
> "-i", "-l" },
>                 EnumSet.of(**ProcessShellFactory.**TtyOptions.ONlCr)));
> } else {
>    sshd.setShellFactory(new ProcessShellFactory(new String[] { "cmd.exe "},
>                 EnumSet.of(**ProcessShellFactory.**TtyOptions.Echo,
> ProcessShellFactory.**TtyOptions.ICrNl, ProcessShellFactory.**
> TtyOptions.ONlCr)));
> }
> -------------
>
> Thanks,
> Nilesh.
>
>
> On 2/1/2012 1:03 AM, Vishwanath Hawargi wrote:
>
>> Hi,
>> I am new to Apache SSHD, so apologies for the dumb questions.
>>
>> I am using the standard set of calls to setup the server, port and the
>> factories before starting the server.
>>
>> My requirement is to allow a user to login to a shell, type a command (not
>> scp commands, but my set of commands) (echoing what he types) and when he
>> hits enter,i would like the command to be executed and the output to be
>> dispalyed in the shell.  I have the code to handle the commands, but I am
>> not able to get an interactive shell.
>> (Also, i am on Windows XP; passing "cmd" in shellFactory gives me a dumb
>> and deaf shell :) where nothing happens...)
>>
>> please help, i am sure i am making some silly basic mistakes.
>>
>> thank you.
>>
>>

Re: how to bind ShellFactory and CommandFactory?

Posted by Nilesh Apte <ni...@gmail.com>.
Hi Vishwanath:

following lines from "SshServer.java" (main method) seems to be working 
for a default OS shell.
When I run the server on WinXP and it launches cmd.exe successfully and 
I can run default commands.
-------------
if (OsUtils.isUNIX()) {
      sshd.setShellFactory(new ProcessShellFactory(new String[] { 
"/bin/sh", "-i", "-l" },
                  EnumSet.of(ProcessShellFactory.TtyOptions.ONlCr)));
} else {
     sshd.setShellFactory(new ProcessShellFactory(new String[] { 
"cmd.exe "},
                  EnumSet.of(ProcessShellFactory.TtyOptions.Echo, 
ProcessShellFactory.TtyOptions.ICrNl, 
ProcessShellFactory.TtyOptions.ONlCr)));
}
-------------

Thanks,
Nilesh.

On 2/1/2012 1:03 AM, Vishwanath Hawargi wrote:
> Hi,
> I am new to Apache SSHD, so apologies for the dumb questions.
>
> I am using the standard set of calls to setup the server, port and the
> factories before starting the server.
>
> My requirement is to allow a user to login to a shell, type a command (not
> scp commands, but my set of commands) (echoing what he types) and when he
> hits enter,i would like the command to be executed and the output to be
> dispalyed in the shell.  I have the code to handle the commands, but I am
> not able to get an interactive shell.
> (Also, i am on Windows XP; passing "cmd" in shellFactory gives me a dumb
> and deaf shell :) where nothing happens...)
>
> please help, i am sure i am making some silly basic mistakes.
>
> thank you.
>