批处理文件和ftp脚本有效,除非与任务调度程序一起使用

时间:2022-05-10 05:25:09

I have written a batch file that calls an FTP script that downloads files from multiple folders from a remote server. When I execute the batch file it works perfectly. However when I schedule it with task scheduler it pulls all the files down except for those in one specific folder.

我编写了一个调用FTP脚本的批处理文件,该脚本从远程服务器下载多个文件夹中的文件。当我执行批处理文件时,它完美地工作。但是,当我使用任务计划程序安排它时,除了一个特定文件夹中的文件外,它会删除所有文件。

I've checked permissions, there are no issues there. The relevant parts of the batch file and FTP script are below. For the purposes of this question I've shortened both. So the question would be why does it download from the "RWSmith" directory but not the "TrimarkFoodcraft" directory when run from Task Scheduler. I know that batch files are not case sensitive but I added the extra suffixes because the files do end in .DAT instead of .dat and they were not downloading.

我已经检查了权限,那里没有问题。批处理文件和FTP脚本的相关部分如下所示。出于这个问题的目的,我缩短了两者。所以问题是为什么它从“任务调度程序”运行时从“RWSmith”目录而不是“TrimarkFoodcraft”目录下载。我知道批处理文件不区分大小写,但我添加了额外的后缀,因为文件以.DAT而不是.dat结尾,并且它们没有下载。

Script and Batch File are on Windows Server 2008 R2 and the server it is downloading from is Windows Server 2003.

脚本和批处理文件位于Windows Server 2008 R2上,从中下载的服务器是Windows Server 2003。

Batch File:


ftp -i -s:ftpCommands.txt 0.0.0.0

FTP Script:


username
password




cd "AdamsBurch"</br>
lcd "C:\EDIScanner\DistributerEDIFiles\AdamsBurch"
mget *.dat
mdelete *.dat


cd \
cd "RWSmith"
lcd \
lcd "C:\EDIScanner\DistributerEDIFiles\RWSmith"
mget *.dat
mdelete *.dat


cd \
cd "TrimarkFoodcraft"
lcd \
lcd "C:\EDIScanner\DistributerEDIFiles\TrimarkFoodcraft"
mget *.dat
mget *.DAT
mdelete *.dat
mdelete *.DAT


close
bye

1 个解决方案

#1


The FTP account might not be in the root directory. After connecting, use pwd to see what directory is current.

FTP帐户可能不在根目录中。连接后,使用pwd查看当前的目录。

username
password
pwd

Instead of assuming the directories are off of the root, use relative references.

不要假设目录不在根目录下,而是使用相对引用。

cd ..
cd "TrimarkFoodcraft"

#1


The FTP account might not be in the root directory. After connecting, use pwd to see what directory is current.

FTP帐户可能不在根目录中。连接后,使用pwd查看当前的目录。

username
password
pwd

Instead of assuming the directories are off of the root, use relative references.

不要假设目录不在根目录下,而是使用相对引用。

cd ..
cd "TrimarkFoodcraft"