Net/ssh question

I am using the synchronized shell in net/ssh.
    shell = ssh.shell.sync

Works like a charm when I use direct methods on the shell:
  out = shell.cd "dir1/dir2"
  # out has #status etc.

Fails when I use send_data
  out = shell.send_data "cd dir1/dir2"
  # out is an Array

Is it supposed to do this?

Yes. #send_data just sends data directly across the pipe, without waiting for any response. The return value is not meaningful, generally.

If you want to send some literal command to the shell without using the method_missing proxy, you can use send_command:

   out = shell.send_command "cd dir1/dir2"

You can pass a string to send to the comamnd's stdin as the second parameter to #send_command, too.

- Jamis

···

On Sep 30, 2005, at 12:46 PM, itsme213 wrote:

I am using the synchronized shell in net/ssh.
    shell = ssh.shell.sync

Works like a charm when I use direct methods on the shell:
  out = shell.cd "dir1/dir2"
  # out has #status etc.

Fails when I use send_data
  out = shell.send_data "cd dir1/dir2"
  # out is an Array

Is it supposed to do this?

great, thanks!

"Jamis Buck" <jamis@37signals.com> wrote in message
news:B9594F4E-4D09-4743-941B-3A0D39F21AA2@37signals.com...

···

On Sep 30, 2005, at 12:46 PM, itsme213 wrote:

> I am using the synchronized shell in net/ssh.
> shell = ssh.shell.sync
>
> Works like a charm when I use direct methods on the shell:
> out = shell.cd "dir1/dir2"
> # out has #status etc.
>
> Fails when I use send_data
> out = shell.send_data "cd dir1/dir2"
> # out is an Array
>
> Is it supposed to do this?

Yes. #send_data just sends data directly across the pipe, without
waiting for any response. The return value is not meaningful, generally.

If you want to send some literal command to the shell without using
the method_missing proxy, you can use send_command:

   out = shell.send_command "cd dir1/dir2"

You can pass a string to send to the comamnd's stdin as the second
parameter to #send_command, too.

- Jamis