-
Notifications
You must be signed in to change notification settings - Fork 258
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
Reading and accepting input from user during execution #639
Comments
sys.stdin is not to read user input (from the keyboard), but the content given to the program at startup, on the standard input flow. |
Thanks Laurent for your reply! I understand now and appreciate your reply. Please be free to close the issue if there is a technical limitation on Gecko that can't support reading inputs live during run-time. |
I don't think gecko supports reading live inputs. Even for reading input, we have to read directly /dev/stdin (so, no support on Windows). And so I was wrong in my previous comment :-) sys.stdin reads what you send to slimerjs as startup (ex: Probably a solution is to call input.read() a first time, to empty the buffer before echoing the question, and then call input.read() until you reach a "\n"? There is however an issue: since SlimerJS open a window, the user has to put the focus on the terminal. But probably with the new headless feature of Firefox, it is not an issue :) (add the |
Thanks Laurent! Got it.. Sounds like it will not be a good idea to implement, because Windows users will experience inconsistency due to the Gecko design. I'll probably not have laptop access for couple of weeks, but will be sure to try out your suggestion when I do and update findings here :) |
(adding some notes that execution didn't reach the sys.stdout.write, it could be something mess up when called from CasperJS. will try running a basic script on SlimerJS when I have laptop again) var casper = require('casper').create();
casper.options.logLevel = 'debug';
casper.start('http://casperjs.org/');
casper.then(function() {
this.echo(this.getTitle());
var input = ''; var sys = require('system');
input = sys.stdin.read();
sys.stdout.write('ENTER INPUT: ');
while (input.indexOf('\n') == -1) input = sys.stdin.read();
this.echo(input);
});
casper.run();
|
Hi Laurent, an update that I have tried it to replicate the behaviour. Below is a minimal SlimerJS script that triggers the error message below. var page = require("webpage").create();
page.open("http://slimerjs.org", function(status){
var input = ''; var sys = require('system');
input = sys.stdin.read();
sys.stdout.write('ENTER INPUT: ');
input = sys.stdin.read();
sys.stdout.write('INPUT IS: ' + input + '\n');
page.close();
phantom.exit();
}) It looks like the flow control didn't make it past the first read() -
|
Hi Using @kensoh last minimal SlimerJS script to replicate I'm able to enter input, though I must do it in ~300ms (linux & i3wm):
Can we somehow halt the script at this particular method or is there a workaround for user input interception (2-factor auth)? Remark: |
versions
Steps to reproduce the issue
Run a bare-minimum script to read input using sys.stdin.read() from SlimerJS doc
Actual results:
Entered something but nothing happens, if nothing is entered script also exits
Expected results:
The input is read correctly and able to be used later on (echo, used as selector etc)
Additional details:
Posted this 2 months ago to a related SlimerJS issue. But it is a closed issue, so I thought to repost here as a new issue. #188 I'm not sure if other users are facing this and not sure if I used the method in the wrong way that's why it's not working. When run with PhantomJS it is ok using sys.stdin.readLine().
UPDATE - forgot to paste the error message received (same as the error I posted in issue 188). This error happens whether I enter something or do nothing and wait for a few seconds for it to appear.
The text was updated successfully, but these errors were encountered: