2
我想將本地驅動器的文件複製到網絡路徑。我知道如何通過使用sft ftp庫(即使用sftp.put(@ local,remote))來實現這一點,但我不知道如何通過使用「sudo」來實現。如果我沒有寫入網絡路徑的權限,該怎麼辦。如何將文件複製到網絡路徑
雖然我可以用下面的代碼刪除網絡路徑文件:
string username = ConfigurationManager.AppSettings.Get("username");
string pass = ConfigurationManager.AppSettings.Get("password");
string filename;
filename = "standalone-full.xml";
string directory1;
directory1 = "apps/instances/express_13000/configuration";
// connecting to machine
SshExec ssh = new SshExec("machine", "user");
ssh.Password = "password";
ssh.Connect();
Console.WriteLine("Connection Established");
// removing files from server
string command_express = "echo" + "'" + pass + "'" + "| sudo -S -u wtsnqa " + "/" + directory1 + "/" + filename + "-exec rm";
string output1 = ssh.RunCommand(command_express);
對於未來的讀者(和死鏈接的可能性),這將是很好的總結鏈接資源的內容的緣故。 –