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

[Process] Implement Expects #20898

Closed
alexbowers opened this issue Dec 13, 2016 · 8 comments
Closed

[Process] Implement Expects #20898

alexbowers opened this issue Dec 13, 2016 · 8 comments

Comments

@alexbowers
Copy link
Contributor

Q A
Feature request? yes

In linux, there is an expect command, which can be setup to deal with interactive programs.

Currently, in symfony there is no way to handle this.

Having the ability to setup expects and have them resolve using symfony would be very useful.

I'm willing to implement this, if it is something that would be considered by the community for merging.

@jakzal
Copy link
Contributor

jakzal commented Jan 25, 2017

@alexbowers thanks for taking your time to make this suggestion! I'm not familiar with the expect command. Would you mind explaining a use case for this kind of functionality in the Process component?

@alexbowers
Copy link
Contributor Author

alexbowers commented Jan 25, 2017 via email

@alexbowers
Copy link
Contributor Author

alexbowers commented Jan 25, 2017 via email

@nicolas-grekas
Copy link
Member

Not sure what that would mean. What's missing? What's expected?
@alexbowers would you be able to work on this one?

@alexbowers
Copy link
Contributor Author

I had a quick look into it, but wasn't able to figure it out.

I may be able to spend a little more time on it.

What is desired is how the expect command works.

What this allows is for you to effectively use Symfony to type input into another command that is running within Symfony.

This is useful for typing in passwords, choosing configuration options where flags aren't available, etc.

You basically would tell it to wait for an output, and respond with some input.

@alexbowers
Copy link
Contributor Author

The basic syntax I was thinking was:

<?php

$cmd = new Process("...");
$cmd->expect("Enter your password:", env("password"));
$cmd->run();

This would cause the command to read the output per line, and when it see's "Enter your password:" then it will put the value from the second argument and "press enter".

I can't figure out how to do this unfortunately.

How do we read output, and how can we pass input in?

@alexbowers
Copy link
Contributor Author

I can see that in some way I need to be able to call pipes->write but, I can't figure out how to best structure that.

@nicolas-grekas
Copy link
Member

Closing as this is not something we should do in core IMHO.

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

No branches or pull requests

4 participants