Batch file and ftp script works, unless used with task scheduler - batch-file

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.
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.
Script and Batch File are on Windows Server 2008 R2 and the server it is downloading from is 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

The FTP account might not be in the root directory. After connecting, use pwd to see what directory is current.
username
password
pwd
Instead of assuming the directories are off of the root, use relative references.
cd ..
cd "TrimarkFoodcraft"

Related

deleting multiple files From FTP

Is there any way to delete all files From FTP. i'm able to delete single files,but not able to delete all the files.I've tried below script but not working for multiple files.
ftp
open <SERVER>
<Usename>
<Pass>
cd </file_location>
delete *.xlsx`
bye
"It's showing Error,No such(*.xls files)".
If I use delete File_Name then it's working.I've also tried mdelete and rm. Please help me how can i delete all the files with .xlsx extension.
mdelete would have worked if you disabled prompting first.
ftp
open <SERVER>
<Usename>
<Pass>
cd </file_location>
prompt
mdel *.xlsx
bye

transfer file from filezilla to local path C:\ using batch file

I have .txt files in FileZilla server. I need to transfer files from FileZilla server to Local Path C:\
Below is the code i am running in job schedule,
prompt
lcd C:\
open sftp.getixhealth.com 20**strong text**2
abcd
xyz
bin
cd /In
mput *.txt
Quit

FTP script failing [duplicate]

This question already has answers here:
How to ftp with a batch file?
(10 answers)
Closed 4 years ago.
I am trying to create a script which copies the contents of one directory to an FTP location but every example I have tried to work with has failed. I need this to target a folder within the FTP site can anyone point me in the right direction.
Thank you
Batch file is below.
#ftp -i -s:"%~f0"&GOTO:EOF
open 0.0.0.0
name#address.com
Pa55word
!:--- FTP commands below here ---
lcd c:\program files\system\location
cd storage
binary
mput "*.*"
disconnect
bye
Once FTP is open you are no longer at a command prompt. You are inside FTP. You need to use your batch file to write the ftp script,FTPInstructions.ftp in the following example. Then open ftp, telling it to run the script.
When you invoke the ftp.exe program to run the ftp script from the batch file you can redirect the ftp.exe console output to a log file and examine that log file for errors. You'll need to redirect both stdout and stderr. Something like this:
echo open 0.0.0.0>FTPInstructions.ftp
echo user UserName>>FTPInstructions.ftp
echo Password>>FTPInstructions.ftp
echo something>>FTPInstructions.ftp
echo something else>>FTPInstructions.ftp
.
.
echo bye>>FTPInstructions.ftp
ftp.exe -n -s:FTPInstructions.ftp>FTPSession.log 2>&1
You can then use FIND or FINDSTR in the batch file to locate any error messages output by ftp.exe in the FTPSession.log file.

mysqldump batch script runs but leaves empty file

I have made a simple batch script to back up a database, however when it runs it creates a empty file. This batch script is located in the same folder where mysqldump.exe is located. Following code:
#ECHO off
start /wait mysqldump.exe -u user -p "password" database > "Z:\sql-backup\"database-backup.sql
Any help would really help. New to Batch scripting.
I had used the below commands in batch file and it has worked properly.
First of all you should goto bin directory and issue the below mentioned mysqldump command. The same you can mention in the batch file as it is.
cd C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin
mysqldump -uroot -ppassword database > "C:\ProgramData\MySQL\MySQL Server 5.6\Data\"Database_bkp.sql

A batch file to download and delete files from a server

How can I write a MS dos ftp batch file to:
download files from the server to my local pc
remove these files from the server after download
Edit:
So far I have...
Batch file:
ftp.exe -s:ftp.txt
FTP.txt:
open domain.com
usernamehere
passwordhere
cd /httpdocs/store/files
need get, list and delete commands here??
quit
The ftp.exe program can take a sort of script file as input (that example uploads a file, but I guess to get the idea), so you should probably be able to create a script for the commands that you need to carry out, and then have a batch file launch ftp.exe with the appropriate input.
From one of my cuestions in other post.
user-name
user-password
lcd c:\localfolder-where-download
cd remote-folder
mget .
mdelete \\remote-folder\ .
quit
1 & 2 line , your credentials
3 - line local folder where the ftp can download the content
4- line - remote folder if needed
5- line - get al content to your local folder
6- line - delete all content from your remote folder
7- line quit!
you can download ncftpput/ncftpget. With ncftpget, there's option to remove remote files after downloading.

Resources