We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
How can we get the output result of a command ?
I created a swift file with the following content:
import Foundation import SwiftSH class sshShell { func executeCMD(cmd:String) -> String { let command = Command(host: "192.168.1.50", port: 22) var output:String = "" command!.connect() .authenticate(.byPassword(username: "user1", password: "password1")) .execute(cmd) { (cmd, result: String?, error) in if let result = result { print("here") print(result) output = result } else { print("there") output = "ERROR" } } return output } }
And in the ContentView, I have:
var output: String = "" Button(action: { let atest = sshShell() output = atest.executeCMD(cmd: "/bin/ls -la") }, label: { Text("Click me") }) Text(output) .padding()
Here is the debugger output:
DEBUG: Timeout set to 10.0 seconds INFO: Libssh2 v1.9.0 DEBUG: 192.168.1.50 resolved. 1 addresses INFO: Connection to 192.168.1.50 on port 22 successful DEBUG: Remote banner is SSH-2.0-OpenSSH_8.6 DEBUG: Fingerprint is BF:... DEBUG: Supported authentication methods: [Public Key, Password, Keyboard Interactive] DEBUG: Authenticating by Password DEBUG: Opening the channel... DEBUG: Environment: [] INFO: Bye bye DEBUG: Disconnected
The connection seems OK but no result.
The text was updated successfully, but these errors were encountered:
Have you found a solution?
Sorry, something went wrong.
No branches or pull requests
How can we get the output result of a command ?
I created a swift file with the following content:
And in the ContentView, I have:
Here is the debugger output:
The connection seems OK but no result.
The text was updated successfully, but these errors were encountered: