Question

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?

Était-ce utile?

La solution

Try:

client.Connect();
SshCommand cmd = client.RunCommand(message);
var output =cmd.Result;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top