Skip to content
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

Invalid example of ssh command #33

Open
nmingotti opened this issue Apr 23, 2020 · 3 comments
Open

Invalid example of ssh command #33

nmingotti opened this issue Apr 23, 2020 · 3 comments

Comments

@nmingotti
Copy link

Hi, I am very new to iPhone programming, the first and most useful thing I may need to do with my phone is exactly to check server statues. So, I would really like to be able to send a command to a remote server and get the STDOUT,STDERR and exitcode.

In the example provided for 'Execute ssh command' I don't understand where the command for the server really is. Suppose I want to run a simple ls -la, it is not clear at all to me where to write ls -la. I tried to guess it without luck. Any help would be very much appreciated.

let command = Command(host: "localhost", port: 22)
// ...
command.connect()
       .authenticate(.byPassword(username: "username", password: "password"))
       .execute(command) { (command, result: String?, error) in
           if let result = result {
               print("\(result)")
           } else {
               print("ERROR: \(error)")
           }
       }
@nmingotti
Copy link
Author

Here is how i would write it, to make it more understandable:

let command = Command(host: "localhost", port: 22)
let cmd = "ls -la ; uptime"
// ...
command.connect()
       .authenticate(.byPassword(username: "username", password: "password"))
       .execute(cmd) { (cmd, result: String?, error) in
           if let result = result {
               print("\(result)")
           } else {
               print("ERROR: \(error)")
           }
       }

@avneet-01
Copy link

@nmingotti Is this library used with Objective-C or Swift? Because after installing the Podfile, when I tried importing it in my Swift ViewController, I got the error "Could not build Objective-C Module 'SwiftSH'". Please let me know how to use this library?
Thanks in advance!

@nmingotti
Copy link
Author

hi @avneet-01 , it is swift. it is several month i don't do phone dev. i can't help sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants