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

Pipes causes bizarre behavior: command output from wrong command piped in. #54

Open
agiles231 opened this issue Dec 4, 2018 · 2 comments

Comments

@agiles231
Copy link
Contributor

Suppose you have 4 commands, A, B, C, D and you run:
A | B
C | D

In some situations, issues will arise where D receives output from A instead of C. I am not sure as to cause and not entirely certain if it is replicable. I worked around this issue by changing the waitPause to a sufficient amount of time, server dependent. If desired, I can work on adding a method specifically for piping output of one command into another. e.g.
pShell.executeCommand("Get-ADUser").pipe("Select-Object whenCreated");

@pradeepnair87
Copy link

Even I see a similar issue. What i have noticed is that the previous command has failed( timed out), the next command on the same session returns an output from previous command.
jpowershell.execute(cmd1) => ran successfully
jpowershell.execute(cmd2) => timed out
jpowershell.execute(cmd3) => returns response of cmd1.

@pradeepnair87
Copy link

pradeepnair87 commented Nov 21, 2020

PowerShellCommandProcessor commandProcessor = new PowerShellCommandProcessor("standard", p.getInputStream(),
this.waitPause, this.scriptMode);
The inputStream is shared across threads. And in the constructor of PowerShellCommandProcessor, we don't clear the previous read data, if any.
So when time out occurs, although the methods returns a timeout error, the data is available in the input stream and the next command reads the already available data and returns almost immediately with the previous data which was not read from the stream. This will result in subsequent calls to return the previous data even with out timeout as the stream already has unread data.

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

2 participants