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
Failed to execute long command by using /bin/bash -c xxx #527
Comments
The ProcessError you are getting is because of a non-zero return code from the command you are running. If you print out the value of result.stderr, it might give you an idea of why it is failing. My guess is that it may be because you have spaces in the command you're trying to run and you're not putting the argument after the "-c" in quotes. Since you have quotes in the command itself, though, that may get tricky to do. You'd have to make sure you do the usual things to properly nest quotes in a shell command. I saw the earlier version of this where you tried passing the command in as an "input" argument. That could avoid this issue, but you'd need to remove the "-c" in that case or you'll be getting an error about a missing argument. In fact, you'd probably want to remove the command entirely, and just let SSH start up an interactive shell you feed with the "input=". |
oh nice, it works by using result = await conn.run(input=command, check=False) but above code only work for bash script, how if the entrypoint as a python? i.e: |
I think the same "input=" option should work for Python code. Just pass in 'python' as the command, possibly with an absolute path, if python isn't on the default remote shell's path. In other words: result = await conn.run('/usr/bin/python3', input=command, check=False) This is actually a bit different from when you leave out that first argument as SSH will exit the remote session when the Python script exits, rather than waiting for additional input (additional shell commands), but pretty much any command you want to run which accepts input from stdin should be able to work with "input=". |
For example I have dynamic entrypoint & commands:
Given: entrypoint
/bin/bash
or/usr/bin/python3
Given dynamic string command, i.e:
Given
/root/.bash_history
already have log of"Hello world!"
Then trying to execute with this asyncssh:
and the result:
The text was updated successfully, but these errors were encountered: