在 FTP 上向 CSV 文件添加行的批处理文件

Batch file to add line to CSV file on FTP

为什么这行不通?我想 edit/add 行到存储在 FTP 服务器上的 CSV 文件。这与网络共享一起工作。

echo %ordrenr%, %teknikker%, %starttime%, %winupdatestarttime%, %endtime%, >>ftp://username:password@192.168.1.241\data\data.csv

您不能将 Windows 命令输出重定向到 FTP。仅对文件或设备。

您必须将行存储到临时本地文件,然后使用 FTP 客户端将本地文件附加到远程文件:

@echo off

rem Create a record in a temporary local file
echo %ordrenr%, %teknikker%, %starttime%, %winupdatestarttime%, %endtime%, > line.txt

rem Use ftp to append the line to a file on the FTP server
(
echo open 192.168.1.241
echo user username password
echo append line.txt data/data.csv
echo bye
) | ftp.exe -n

rem Remove temporary file
del line.txt