我正在尝试通过 SSH 在我的 UNIX 机器上执行 perl 脚本。我已经设法连接到机器并执行“ls”和“man chmod”,但是当我尝试“perl /test/temp.pl”或“perl a”时,我什么也得不到。
我正在使用的代码如下
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);
}
有人遇到相同或类似的问题吗?