powershell transfer txt file always binary

Advertisement

dafinch
Guest

powershell transfer txt file always binary

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,459
Location:
Prague, Czechia

Re: powershell transfer txt file always binary

What do you mean by "file is a binary file"?
_________________
Martin Prikryl

Reply with quote

dafinch
Guest

binary file

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.

Reply with quote

Guest

Figured it out

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.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,459
Location:
Prague, Czechia

Re: Figured it out

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

Reply with quote

Advertisement

You can post new topics in this forum