FTP Batch Files

I know you can create a FTP batch file that will connect to ftp site automatically.  My question is, can you include more than 1 batch file or sets of commands in the same .bat file.  I currently run 1.bat file to connect FTP, and copies the 2nd.bat file from ftp to local computer and runs. (Having a total of 2 batch files)

Can you create multiple batches in 1.bat file?
If not, how can I Call or run other batches after I connect to FTP within the same batch file?
LVL 1
POINTGREENAsked:
Who is Participating?
 
Steve KnightIT ConsultancyCommented:
Some of the FTP methods for batch are here btw if you need more info:
http://scripts.dragon-it.co.uk/links/batch-ftp-scripting

then you would have somehing like:

@echo off
REM Script to retrieve 2.bat into c:\batch
ftp -s ftpscript.txt
cd /d c:\batch
call 2.bat
REM Carries on here after 2.bat finishes.
0
 
Steve KnightIT ConsultancyCommented:
Not quite sure what you are after, but I think you are saying you have, say,

1.cmd (or 1.bat) which uses FTP.exe to retrieve 2.cmd (or 2.bat).
Then you want 1.bat to pass control to the downloaded 2.bat.

There are four main ways if so:

1. Just add 1.bat to the next line of the batch, with the path to it if needed.  It will pass control to that other batch file and  NOT return to the first

2. Add CALL 2.bat with path if necessary.  It will pass control to the other batch and then return to the next statement in 1.bat

3. START 2.bat. It will run 2.bat in another window and at the same time carry on to the next statement.

4. START /WAIT 2.bat.  It will run 2.bat in another window and wait for it to finish then continue (similar to #2).

If this isn't what you want perhaps best to post your current script(s) to check.

Steve
0
 
POINTGREENAuthor Commented:
I accidentally deleted this question.  
0
 
Steve KnightIT ConsultancyCommented:
As to your other question ypu posted bu seems was deleted too, if you have an account on the remote machine and it is accessible via windows then you can uses psexec to run a program or batch file.
Other way depending upon the requirements is to have a batch constantly running on the remote machine which, say, does:

@Echo off
:start
if exist c:\ftpdir\2.cmd START /WAIT c:\ftpdir\2.cmd
del c:\ftpdir\2.cmd
ping 127.0.0.1 -n 61
goto start

i.e. loop around every 60 secs and run the batch file in the ftp space if it exists.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.