Subject: SFTP from Windows to Unix
Date: 2013-10-16 07:17:33
From: Finn Bidstrup
Source: sftp-windows-unix
----------------------------------------------------------------------

I am uploading a file from a Windows-server to a Unix-server using the Ultimate SFTP component.

Here is the code – it works fine:

[code lang='vb']

 'Create a new instance.

  Dim client As New Sftp()

  Dim DestinationPortNr As String = DestinationPortNumberr

 

 'Connect to the SFTP server.

  Dim HostServer As String = DestinationIP

  client.Connect(HostServer, DestinationPortNr)

 

 'Authenticate.

  Dim Bruger As String = user

  Dim Password As String = password

  client.Authenticate(user, password)

 

 'Change current directory to inbox.

  client.SetCurrentDirectory(UploadDirectory)

 

 'Upload local file

  client.UploadFile(FilOgStiNavn, NavnXmlFil)

 

 'Disconnect.

  client.Disconnect()

[/code]

 

The file that I move is an ascii-file.

If I open it in Notepad++ (before moving it) I can see that the format is UTF-8, and the content looks like this:

Content of file – before the upload (windows environment)

06105200OP2005481111                                                           

06105200OP0401601111                                                           

06105200OP1306642222                                                            

06105200OP0405962222                                                           

06105200OP1509012222                                                           

 

however on the destination server (Unix) it is not readable. It looks like this:

Content of file – after the upload (Unix environment)

********************************* Top of Data **********
........|&.............................................................              <<=======
******************************** Bottom of Data ********
 

In my code I have tried to experiment with “TransferMode” and “ServerOS”:

[code lang='vb']

Dim RemoteServerOS As String = client.ServerOs

client.ServerOs = Atp.IO.RemoteServerOs.Unix

 

Dim Filtype As String = client.TransferMode

client.TransferMode = SftpTransferMode.Binary

[/code]

but without any luck. The file is still looks funny when it arrives at the destination server.

I have used the SFTP component a lot of times and transferred different files using the same code without any format-problems. I therefore suspect that it is the Unix-server that causes the problem?

Can you help me please?

Thanks in advance.

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index