尝试使用拥有所有权限的用户运行 sudo 命令,但我的代码有问题。
我正在尝试通过 C# 代码删除远程服务器上存在的文件。它说:名称'pass'在当前上下文中不存在。:
我的代码:
SshExec sshExec = new SshExec("sj1slm612", "karansha");
sshExec.Password = "pass";
sshExec.Connect();
//Removing config files from sj1slm612 server
string remove_config_file_express = "echo " + "'" + pass + "'" + "| sudo -S -u wtsnqa rm " + "/apps/instances/express_13000/configuration/standalone-full.xml";
string output_express = sshExec.RunCommand(remove_config_file_express);
Console.WriteLine("All config files removed");
Console.ReadLine();