PuTTY PSFTP returning error: unknown command "´╗┐cd"

PuTTY PSFTP returning error: unknown command "´╗┐cd"

嗨,我 运行 在我的 Windows 服务器的命令下。我已经添加了私钥,因此身份验证很好。但是每当我 运行 命令遇到一个奇怪的问题时

psftp user@host -b FTPfile.txt

文件FTPfile.txt 只有两行。

cd /apps/scripts/batch/sln/input
put Test.txt

但我收到错误消息 psftp: unknown command "´╗┐cd"

而且我注意到文件第一行给出的任何命令 returns 都有类似的错误。

问题是 FTPfile.txt 以 Unicode byte order mark (U+FEFF) encoded in UTF-8, which corresponds to the bytes 0xEF 0xBB 0xBF. psftp thinks those bytes are part of the command name. When it prints those bytes to the console as part of the error message, they're interpreted according to code page 850 开头,这使得它看起来像 ´╗┐

要解决此问题,您需要删除 BOM。您是如何创建 FTPfile.txt 的? Windows 文本编辑器通常具有将文件编码更改为 "ANSI" 的设置(普通 ASCII 也可以)。