How to spawn a PTY in one line

Hi

Is there any pure and native ruby way to spawn an interactive shell in *one
line* that can interacts with interactive *passwd* commands.

In python, this is the code

*python -c 'import pty; pty.spawn("/bin/sh")'*

Note: I tried all kind of methods like *system*, *exec*, *backticks*, ruby
*pty* nothing works

Why I need that?
Assume I've a remote shell via netcat and I need to change the user
password using *passwd* commandline

Thanks

···

--

*Senior Information Security Engineer OSCE, GWAPT, **CEH, **OSCP, **RHCE, *
*CCNA, **MCITP-EA*

Hi,

Is there any pure and native ruby way to spawn an interactive shell in *one
line*

Since process spawning is an inherently OS-specific operation, there
can't be a pure-ruby implementation of that. If you mean "native" in the
sense that it is included in the core or stdlib, there are #spawn,
#system, IO.popen, the backticks, and given the Python code you posted,
the PTY library[1].

Note: I tried all kind of methods like *system*, *exec*, *backticks*, ruby
*pty* nothing works

It appears you have already found PTY. So instead of "does not work",
please be more specific about what does not work. Does it fail to spawn
the process? Does it crash with an exception?

Greetings
Marvin

[1]: Module: PTY (Ruby 2.3.2)

···

On Sun, Nov 20, 2016 at 12:50:05AM +0300, KING SABRI wrote:

--
Blog: http://www.guelkerdev.de
PGP/GPG ID: F1D8799FBCC8BC4F

Hi,
Yes, I meant native.

I've tried many solutions with PTY but and "does not work" means the
interactive session never shows up, it never allows the connected machine
to interact with commands line *password* and the session hangs

···

On 20 November 2016 at 16:36, Marvin Gülker <m-guelker@phoenixmail.de> wrote:

Hi,

On Sun, Nov 20, 2016 at 12:50:05AM +0300, KING SABRI wrote:
> Is there any pure and native ruby way to spawn an interactive shell in
*one
> line*

Since process spawning is an inherently OS-specific operation, there
can't be a pure-ruby implementation of that. If you mean "native" in the
sense that it is included in the core or stdlib, there are #spawn,
#system, IO.popen, the backticks, and given the Python code you posted,
the PTY library[1].

> Note: I tried all kind of methods like *system*, *exec*, *backticks*,
ruby
> *pty* nothing works

It appears you have already found PTY. So instead of "does not work",
please be more specific about what does not work. Does it fail to spawn
the process? Does it crash with an exception?

Greetings
Marvin

[1]: Module: PTY (Ruby 2.3.2)

--
Blog: http://www.guelkerdev.de
PGP/GPG ID: F1D8799FBCC8BC4F

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--

*Senior Information Security Engineer OSCE, GWAPT, **CEH, **OSCP, **RHCE, *
*CCNA, **MCITP-EA*

Please,
* what you want to achieve (do you want to forward the IO of a remote
passwd command or do you want to present a prompt for the user to
enter their password and then send it over?)
* mention the platform you are trying this on, including Ruby version
* show the code that you executed
* show output, presumably with errors

Otherwise it is practically impossible for the group to come up with
helpful advice.

Btw. how do you set up a "remote shell via netcat"?

Kind regards

robert

···

On Sun, Nov 20, 2016 at 6:19 PM, KING SABRI <king.sabri@gmail.com> wrote:

I've tried many solutions with PTY but and "does not work" means the
interactive session never shows up, it never allows the connected machine to
interact with commands line password and the session hangs

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/