Closed rvan1 closed 6 months ago
Looks like I never added a way to specify arguments as part of the client execute_cmd API. You are achieve the same thing by doing execute_ps
here though. Your example should work as is there. Otherwise you can use the underlying low level API that execute_cmd
is wrapping.
from pypsrp.shell import WinRS, Process, SignalCode
from pypsrp.wsman import WSMan
with WSMan("server", ...) as wsman, WinRS(wsman, codepage=65001) as shell:
process = Process(
shell,
"cmd.exe",
arguments=["arg1", "arg2"],
)
process.invoke()
process.signal(SignalCode.CTRL_C)
rc = process.rc
stdout = process.stdout.decode("utf-8")
stderr = process.stderr.decode("utf-8")
OK thanks. Sorry to waste your time as I was trying to test some difficult scenarios. It's seems that the client actually will take the arg along with the cmd no problem. The console app originally read/loaded files form 'inbound' directory, but now I've built a version with slightly different name and I'm passing a specific filename via CLI arg so it will only load that one, regardless of other files. The app is also using newtonsoft.dll to parse a few json values I set up in the app config, as a way to inject alternate 'done' paths to move file to. By convention, the config filename has to match the app filename, but I didn't provide one when I moved the app to test on a different server. Since it had no proper conf file, when newtonsoft went to read the json, there was a string arg can't be null error, which I confused with meaning my filename arg wasn't getting passed in, but the error isn't about that.
Command to run fileloader app with filename argument doesn't work. The app responds with ArgumentNullException - the argument value can not be null.
client.execute_cmd("C:\opt\loader\Load834.exe XYZ_834_20240501.EDI")
Why doesn't it just run the command with argument as I've passed them in?
That's pretty typical isn't it, passing a CLI argument to a console app?