Closed dbuskariol closed 5 years ago
Yes this is possible!
try ssh.execute("ls", output: { (chunk) in
// do something with the output chunk
})
Awesome, thanks for the reply @jakeheis! I tried using what you wrote, however I still have the same issue:
try ssh.execute(command, output: { (chunk) in
print(chunk)
})
This will show nothing until the command finishes, then print everything at once. When I SSH in manually through terminal though, I see the output of the script as it happens.
Hm that's strange. I used this to test it:
import Shout
let ssh = try SSH(host: "mysite.com")
try ssh.authenticateByAgent(username: "user")
try ssh.execute("while true; do sleep 1; echo hello; done", output: { (chunk) in
print(chunk, terminator: "")
})
This command would execute forever, but when I executed this program the output appeared line by line as it should. Shout
seems to be calling the output closure correctly in my case, so I wonder if this is something unique to the command you are calling. Is it a standard unix command?
Closing, feel free to open with more information if need be
I've managed to get Shout up and running :) I'm wondering if it's possible to get the output of a command as it's running, rather than the output at the end of the command being run. For example, the script I am running with Shout over SSH has output I'd like to show in my swift app. Currently it runs but will only print the whole output at once at the end of execution.
Is this possible?