SSH.NET won't allow this string

Sorry if i've overlooked something silly...

using (var client = new SshClient("ipaddress", "USER", "PASSWORD"))
{
    client.Connect();
    string xnatCli = @"XNATRestClient -host http://localhost:8080/xnat/ -u admin -p administrator -m PUT -remote ""/data/archive/projects/prj005/subjects/test12/experiments/visit12?xnat:petSessionData/date=12/12/12" + "\"";

    //string list = "ls -lrt";

    var cmd = client.RunCommand(xnatCli);
    cmd.Execute();
    var outputQuery = cmd.Result;
    Console.Write(outputQuery);
    Console.Read();
 }

Dear developers..I'm hoping that someone can help me..I'm quite stuck for ideas to why this would not work. I've tried simple commands as illustrated above ls -lrt in RunCommand(). It worked fine used putty or ssh'ing from another linux machine with the command(xnatCli) works fine. However will not work in this code instance. String length limitation on ssh.net.RunCommand() maybe? Am i doing something silly?

Answers


try using StringBuilder instead of string:

        StringBuilder response = new StringBuilder();

        SshClient client = new SshClient("host", "user", "pass");
        client.Connect();
        var cmd = client.RunCommand("ls -la");
        cmd.Execute();
        response.Append(cmd.Result);
        client.Disconnect();

Hope it helps.


Try this code:

string xnatCli = "your command here";

SshCommand cmd = client.CreateCommand(xnatCli);

cmd.Execute();

Need Your Help

jquery variable outside function

jquery function variables

How can I update a variable outside of a function? For example I have this: