Topic "powershell transfer txt file always binary"

Author Message
dafinch

Guest


I'm trying to transfer a text file from a windows server to a linux server. I am able to transfer the file but when I look at the file is a binary file.


$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Ascii

$transferResult = $session.PutFiles("c:\test.txt", "/tmp/", $FALSE, $transferOptions)

I've got the transfermode set to Ascii. Not sure what i'm doing wrong.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
What do you mean by "file is a binary file"?
_________________
Martin Prikryl
dafinch

Guest


When I attempt to look at the file from a linux prompt I get a prompt that "text.txt" may be a binary file. See it anyway.

And instead of seeing Hello World! I see

<FF><FE>h^@e^@l^@l^@o^@ ^@w^@o^@r^@l^@d^@!^@^M^@
^@
test.txt (END)

Usually when I less a text file I don't see that warning and just see the text.
Guest




Sorry I figured out my issue. The files needed to be converted from dos format cr/lf to unix. Once that was done they worked.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Anonymous wrote:
Sorry I figured out my issue. The files needed to be converted from dos format cr/lf to unix. Once that was done they worked.

Well, that's what the ascii transfer mode should do for you automatically. Please attach a complete session log file.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License