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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Rydell
Posts: 11
Joined: 02 May 2013 17:45

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

#1 Post by Rydell » 03 Jun 2013 16:15

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.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 03 Jun 2013 17:58

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.

Rydell
Posts: 11
Joined: 02 May 2013 17:45

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

#3 Post by Rydell » 03 Jun 2013 23:27

Aye, I got it from here:

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

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

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

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

#4 Post by Aacini » 04 Jun 2013 00:37

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!

Rydell
Posts: 11
Joined: 02 May 2013 17:45

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

#5 Post by Rydell » 04 Jun 2013 01:30

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.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#6 Post by Squashman » 04 Jun 2013 05:48

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.

Post Reply