jPowerShell: "$pid" command failing on initialize
As a user of earlier versions of jpowershell, I’ve upgraded to 3.0.1, but cannot seem to get off the ground.
When attempting to openSession(), at line 168 the PowerShell.inialize method fails whenh parsing the result of the $pid command. In my case it is always an empty string and throws NumberFormatException.
//Get and store the PID of the process
this.pid = Long.valueOf(executeCommand("$pid").getCommandOutput());
I’ve tried configuring my own powershell (powershell-core) and the default installation of PowerShell in my environment. I’ve adjusted timeouts to give powershell more time to start since it appears the resultant “” is because PowerShell never gets started and cannot execute executeCommand("$pid") on line 168. This results in a NumberFormatException.
Used jpowershell.properties to set maxWait so that openSession is effected. maxWait:30000 and greater values.
Have tried nearly every variant of simply calling openSession and it fails regardless as described.
try(PowerShell powerShell = PowerShell.openSession()) {
PowerShellResponse response = powerShell.
executeScript(pathToScript);
log.info("{}", response);
}catch(Exception e) {
log.error("{}", e.getMessage());
}
It seems the cause is that:
-
PowerShell is not getting launched,
-
A timeout occurs waiting on the response to the subsequent
"$pid"command, which results in “” -
this.pid = Long.valueOf(executeCommand(“$pid”).getCommandOutput()); throws NumberFormatException on the resultant empty string.
I’ve ensured that powershell is available either as the default ‘powershell.exe’ or a custom powershell installation. No matter which configuration I try it seems Powershell is not started. Any Ideas on my problme?
As a secondary item, in working my problem I think the line in bullet 3 should be changed to handle this situation better?
Any help would be appreciated. Thanks
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 21 (8 by maintainers)
v3.0.4 is published
@profesorfalken Im out of office, could you please make the change
@profesorfalken works fine with 3.0.2 thank you.