【问题标题】:Batch file to add line to CSV file on FTP在 FTP 上将行添加到 CSV 文件的批处理文件
【发布时间】:2015-09-03 08:56:02
【问题描述】:

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

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

【问题讨论】:

  • @wOxxOm 正如你所说的“上传”我猜没有办法“编辑”文件?所以我打算这样做,使用ftp从我的ftp服务器下载文件,然后使用echo %ordrenr%, %teknikker%, %starttime%, %winupdatestarttime%, %endtime%, >>c:\data.csv在计算机上编辑,然后上传到ftp。

标签: batch-file ftp


【解决方案1】:

您不能将 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

【讨论】:

    猜你喜欢
    • 2011-12-17
    • 1970-01-01
    • 2017-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    相关资源
    最近更新 更多