1

I am trying to execute perl scripts on my UNIX machine, through SSH. I have managed to connect to the machine and execute "ls" and "man chmod", but when I am trying "perl /test/temp.pl" or "perl a", I don't get anything back.

The code I am using is the following

PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo(host, user,pass);
using (var client = new SshClient(connectionInfo))
{
    client.Connect();
    var cmd = client.CreateCommand(script);
    string result = cmd.Execute(script);
    var reader = new StreamReader(cmd.OutputStream);
    var output = reader.ReadToEnd();
    Console.Out.WriteLine(result + "_output:" + output);
}

Anybody having the same or similar issues?

1 Answer 1

5

Try:

client.Connect();
SshCommand cmd = client.RunCommand(message);
var output =cmd.Result;
Sign up to request clarification or add additional context in comments.

1 Comment

I have quit this approach and used another one, so I can't even test it any more. I am accepting your answer because I trust that you have tested something similar at least :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.