scp odd behavior

Mar 6, 2013 at 8:27 PM
I'm able to login to a server and execute scp commands using your library. I'm getting a weird behavior on upload. I need to upload a file to a folder off of the root called "in", but when I perform the upload command and setting the destination to "/in/testfile.txt" it gives me an "ambigous target" error. If I use "in/testfile.txt" it creates the file, but does so by creating a second in folder and putting the text file in there resulting in the file beingn in "/in/in/testfile.txt". Here is my code
    public string putfile()
    {
        string status = "success";
        string testfile = Server.MapPath("/App_Data/test2.txt");
        string destfile = "in/" + Path.GetFileName(testfile);
        try
        {
            var conn = connect3();
            ScpClient m_scpclient = new ScpClient("192.168.0.0.1", 22, "username", new PrivateKeyFile(File.OpenRead(@"C:\keys\myprivatekey.ppk"), "keyphrase"));
            //SftpClient m_sftpclient = new SftpClient(conn);
            m_scpclient.Connect();
            //m_sftpclient.Connect();
            if (m_scpclient.IsConnected)
            {
                status = destfile;
                
                m_scpclient.Upload(File.OpenRead(testfile), destfile);
                //m_scpclient.Upload(File.OpenRead(testfile), @"\in\" + Path.GetFileName(testfile));
            }
            else
            {
                status = "disconnected";
            }
        }
        catch (Exception ex)
        {
            status = ex.ToString() + destfile + testfile;
        }
        return status;
    }

any help figuring this out would be greatly appreciated. I've tried several differentn combinations of backslashes, using "..\", "../". Everything gives the ambigous target error except the version that creates the duplicated directory. If I try it with just the file name it gives me an error because I don't have permissions to deposit files in the root.
Coordinator
Mar 6, 2013 at 8:38 PM
Hi,

Unfortunately I do have some problems with SCP right now.

I am planning to review this client as soon as I have more time since I have few more related issues.

Thanks,
Oleg
Mar 6, 2013 at 8:47 PM
okay... I can probably deal with this for now, but would be nice if I could figure out how to stop this behavior!
Coordinator
Mar 7, 2013 at 4:17 PM
Hi,

Can you please check 23466 commit and see if it fixed that?
I made some change to the logic and it worked correctly in my test.

Thanks,
Oleg
Mar 19, 2013 at 1:02 PM
still not working for me, can you show me the code that you used in your test?
Mar 19, 2013 at 1:24 PM
okay I got this working by passing the upload method a fileinfo instead of a streamwriter. thanks for your help.