Когда я подключаюсь к серверу с помощью библиотеки SSH.NET, папка по умолчанию - /mif/stud3/2014/rira1874
. Когда я выполняюНе удается сменить каталог с C# SSH.NET
res = ssh.CreateCommand("cd existingFolder").Execute();
Console.WriteLine(res);
он по-прежнему находится в папке подключения по умолчанию. Что здесь не так?
полный код:
public void ConnectWithPassword(string username, string password, string domain, int port)
{
bool i = true;
using (var ssh = new SshClient(CreatePasswordConnectionInfo(username, password, domain)))
{
try
{
ssh.Connect();
if (ssh.IsConnected)
{
while(i == true)
{
string res = Regex.Replace(ssh.CreateCommand("pwd").Execute(), @"\r\n?|\n", "");
Console.Write(res + ": ");
res = ssh.CreateCommand(Console.ReadLine()).Execute();
Console.WriteLine(res);
}
}
else {
Console.WriteLine("Not connected");
}
ssh.Disconnect();
}
catch (Exception e)
{
Console.WriteLine("Exception caught: {0}", e);
}
}
}
Я не вижу, чтобы заданный вопрос был таким же, как в вашем коде ---> ваш код имеет 'res = ssh.CreateCommand (Console.ReadLine()). Execute();', тогда как вы говорите about 'res = ssh.CreateCommand (" cd existingFolder "). Execute();'! –
Что я имел в виду, когда я писал «cd existingFolder» в консоли, он по-прежнему не меняет каталог –