Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interactive shell not blocking on shell input #64

Open
lubars opened this issue Jul 20, 2017 · 5 comments
Open

interactive shell not blocking on shell input #64

lubars opened this issue Jul 20, 2017 · 5 comments

Comments

@lubars
Copy link

lubars commented Jul 20, 2017

When I open an interactive session like this, some interactive prompts acts as if they've encountered EOF:

Shell shell = new com.jcabi.ssh.SSH(addr, port, user, key);
int exitValue = shell.exec("bash -i", System.in, System.out, System.err);

Example: "yum install httpd"

$ ./test-jcabi
[centos@localhost ~]$ sudo yum install httpd
Install  1 Package (+4 Dependent packages)
Total download size: 3.0 M
Installed size: 10 M
Is this ok [y/d/N]: Exiting on user command        <-- doesn't block on input
[centos@localhost ~]$

If I run with just "bash" (not "bash -i"), the shell blocks on input correctly, but the prompt doesn't appear until after the input is provided (and there's no shell prompt either):

$ ./test-jcabi
sudo yum install httpd
Install  1 Package (+4 Dependent packages)
Total download size: 3.0 M
Installed size: 10 M
y                             <-- answering before prompt appears
Is this ok [y/d/N]: Downloading packages:
Complete!

I tried wrapping the command in /usr/bin/script to create a valid tty, prepending TERM=xterm, and the piped input/output scheme in this issue, but the result was the same. Any help would be appreciated.

@0crat
Copy link

0crat commented Jul 20, 2017

@yegor256 please, pay attention to this issue

@yegor256
Copy link
Member

@lubars
Copy link
Author

lubars commented Jul 20, 2017

Hi @yegor256. In this case there is a way around it, but I'm seeing this behavior with other interactive applications, and was hoping to come up with a more general solution. Thanks for the reply -

@Lordan
Copy link

Lordan commented Mar 5, 2018

@yegor256 any plans to work on this? I run into problems as well with a rather verbose command which prompts for an input and I couldn't find a way to send the needed input at the right moment. Any example how to read the output until the prompt appears and respond with e.g. 'Y' would be very welcome.

@j-dimension
Copy link

@j-dimension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants