spechal.com | [spesh-uhl]

Nov/09

20

Windows Batch FTP Routine

Here is some example code to connect to an FTP server and run the commands that follow.

@echo on

%windir%\system32\ftp.exe -n -s:"%~f0" server.com
goto done
user myusername
mypassword
cd /home/directory/public_html
ls -al
quit
:done
pause

The key to this working are the following:

The -n switch allows you to not be prompted for a username upon connection.
The -s:”%~f0″ says to use the rest of the file as the commands to execute
The goto command is not a valid FTP command, so the FTP server ignores it.

So you have the script using the Windows FTP utility to connect to a server and a routine running your commands. You can even extend off of this.

RSS Feed

No comments yet.

Leave a comment!

<<

>>

Find it!

Theme Design by devolux.org