Page 1 of 1

Using the @ftp -i -s:"%~f0"&GOTO:EOF command in a batch???

Posted: 03 Jun 2013 16:15
by Rydell
Hey folks, I have a problem with the batch file exiting itself after using this command and then attempting to exit ftp with "bye" or "quit". I'd like it to simply continue onto the next line in the batch like normal. Here's what I got:

@ftp -i -s:"%~f0"&GOTO:EOF
open ftp.filehostingsite.com
username
password

get file.exe
bye


Then the batch closes out of prompt. "Bye" should simply exit out of the ftp syntax, but I have a feeling with the unique way of using ftp here (inside the same batch file) it's going to make things a bit more complicated. I know the traditional way of doing it is simply referencing a separate ftp text document for the ftp commands, but this batch is suppose to be an all in one (does several other things). It would defeat the purpose to include more files.

Re: Using the @ftp -i -s:"%~f0"&GOTO:EOF command in a batch?

Posted: 03 Jun 2013 17:58
by Squashman
The GOTO :EOF kills the batch file as explained in the DosTips library which I assume is where you got the information from.

Code: Select all

Description:   
Embed FTP script into a batch script. Add this line at the beginning of the FTP script:

@ftp -i -s:"%~f0"&GOTO:EOF
The "FTP -s:ftpscript.txt" option executes a FTP script wheres "%~f0" resolved to the name of the running batch file. "GOTO:EOF" ends the batch script and makes sure the FTP script doesn`t run as part of the batch.

Re: Using the @ftp -i -s:"%~f0"&GOTO:EOF command in a batch?

Posted: 03 Jun 2013 23:27
by Rydell
Aye, I got it from here:

http://www.dostips.com/DtTipsFtpBatchScript.php

Do you know of anyway to trick it into not closing?

Re: Using the @ftp -i -s:"%~f0"&GOTO:EOF command in a batch?

Posted: 04 Jun 2013 00:37
by Aacini
Try this:

Code: Select all

@ftp -i -s:"%~f0"&GOTO continue
open ftp.filehostingsite.com
username
password
get file.exe
bye

:continue
echo Here Batch file continues!

Re: Using the @ftp -i -s:"%~f0"&GOTO:EOF command in a batch?

Posted: 04 Jun 2013 01:30
by Rydell
Aacini wrote:Try this:

Code: Select all

@ftp -i -s:"%~f0"&GOTO continue
open ftp.filehostingsite.com
username
password
get file.exe
bye

:continue
echo Here Batch file continues!


w00t! This worked, thanks! It's always something friggin simple.

Re: Using the @ftp -i -s:"%~f0"&GOTO:EOF command in a batch?

Posted: 04 Jun 2013 05:48
by Squashman
Rydell wrote:
Aacini wrote:Try this:

Code: Select all

@ftp -i -s:"%~f0"&GOTO continue
open ftp.filehostingsite.com
username
password
get file.exe
bye

:continue
echo Here Batch file continues!


w00t! This worked, thanks! It's always something friggin simple.

Yeah, I was trying to lead your horse to the water without giving you the answer. I thought maybe if you knew enough about using GOTO that you would have been able to figure it out yourself.