Single command containing semi-colon

Mar 27, 2013 at 11:43 AM
Edited Mar 27, 2013 at 2:03 PM
Hi, I'm trying to run a command containing semi-colons thanks to the SshClient.RunCommand() method but the command doesn't seem to be executed.

The command does work when I'm using it directly.

I was wondering if the semi-colons wouldn't be the problem since they are used to seperate commands otherwise. I guess the problem would be the same for any multiline commands.

If you have any idea on how to bypass this issue, feel free to contribute.

Fyi, the command is:
for dir in `find . -type d -name '*123*'`; do mv "$dir" "${dir/123/321}"; done
Edit: I found the solution, I was not familiar with the ShellStream class.
using (SshClient client = new SshClient(connectionInfo))
{
    client.Connect();

    var stream = p_client.CreateShellStream("xterm", 80, 24, 800, 600, 1024);
    stream.WriteLine("cd " + path);
    stream.WriteLine("for dir in `find . -type d -name '*123*'`");
    stream.WriteLine("do mv \"$dir\" \"${dir/123/321}\"");
    stream.WriteLine("done");
}