# Notepad ftp bat file quaestion



## ve03vsx (Feb 11, 2011)

Hi I'm new here so bare with me

I am trying to make a notepad bat file that can ftp

I connect to the host by typing :

ftp <host address>

then I am prompted for the username which I type on the next line but this is never entered and i am left with the prompt to manually enter the user name. how do I automate this.

Thanks for any help


----------



## TheOutcaste (Aug 8, 2007)

You have to put that info into a text file and run it as a script.
Create a text file with this:

```
open <host address>
username
password
```
The run FTP with the -s switch:
*ftp -s:<filename>*
Type *FTP /?* in a Command Prompt for more info


----------



## ve03vsx (Feb 11, 2011)

Hi Thanks for the help
but.....

I currently enter the following script in notepad saved as a BAT file

ftp <Ip address>
pause

The site I want to ftp connects and asks for the username, but....... if I take it a step further and add the username and password as below

ftp <Ip address>
<username>
<password>
pause

It goes no further and still just asks for the username. I would like to enter the ftp at the click of an icon and not have to enter the username and password each time. 
Any more help for an new B.


----------



## TheOutcaste (Aug 8, 2007)

You need two files, one a text file with the FTP commands, then a batch file to tell FTP to run the script.
Save th1s as *logon.txt*:

```
open <ip address>
username
password
```
Save this as *startftp.bat* in the same folder as *logon.txt*:

```
ftp -s:logon.txt
```


----------



## ve03vsx (Feb 11, 2011)

Hi Outcaste, Thanks for the help that worked a treat, I've got to ask the question though
-s:
This means something in ANSI. Is there a list of these commands and there meanings?


----------



## TheOutcaste (Aug 8, 2007)

It's not ANSI, it a command line switch.


TheOutcaste said:


> Type *FTP /?* in a Command Prompt for more info


For FTP Subcommands (those used in the FTP session itself) see this article:
Ftp subcommands

Not all FTP servers support all of the Subcommands, and there may be some that aren't listed above.


----------



## ve03vsx (Feb 11, 2011)

Hi again.. So here it is..... so far

open <IP>
Username
Password
binary
cd /"need commas for file name with spaces"/"space space" (that took a while to figure)
get "space man" *here*

The command in bold is what it will save as on my computer in the directory I have open at the time. Is there any way to get the script to make a folder (of its own) and save the file into that folder. Then I could ftp multiple files into that folder by various repeats of the script.

? what do you think is it possible?


----------



## TheOutcaste (Aug 8, 2007)

Create the folder first in the batch file before starting the ftp session, then use the lcd (LocalChangeDirectory) command to set the local directory that *get* and *mget* will use.
eacmple:
In the batch file:

```
If Not Exist "C:\My Downloads\Space Man" MD "C:\My Downloads\Space Man"
FTP -s:logon.txt
```
In the logon.txt file:


```
open <IP>
Username
Password
binary
lcd "C:\My Downloads\Space Man"
cd /"need commas for file name with spaces"/"space space"
get "space man"
```
And the *"* is a double quote character, not a comma (*,*), though most of the time it's just referred to as a quote character. They often do look just like two commas, just at the top of the line instead of the bottom.


----------



## ve03vsx (Feb 11, 2011)

Hi Outcaste,

Many thanks for the help so far I'm nearly there. Here where it is so far


```
open <IP>
<USER ID>
<PASSWORD>
binary
lcd "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 logfile"
cd /var/log
get [COLOR=red]messages.0
[/COLOR]get [COLOR=red]messages.1
[/COLOR]get [COLOR=red]messages.2
[/COLOR]get [COLOR=red]messages.3
[/COLOR]get [COLOR=red]messages.4
[/COLOR]get [COLOR=red]messages.5
[/COLOR]lcd "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 OS"
cd..
cd..
cd /etc
get [COLOR=red]version
[/COLOR]lcd "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 App"
cd..
cd /opt/axiontech/etc
get [COLOR=red]version
[/COLOR]lcd "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 SN HW"
cd..
cd..
cd..
cd /var/log/conf
get [COLOR=red]modLevel[/COLOR]
bye
```
and


```
If Not Exist "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1" MD "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1"
If Not Exist "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 logfile" MD "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 logfile"
If Not Exist "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 OS" MD "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 OS"
If Not Exist "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 App" MD "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 App"
If Not Exist "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 SN HW" MD "C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in\PCC1\PCC1 SN HW"
ftp -s:test.txt
```
So my first question is can I save the files under a different file name without changing the ftp servers file names i.e file version remains as file version on the remote computer but I ftp it to my computer and save it as OS level ? 
Secondly how do I get the script to perform the same actions but with a differnet IP address, so that once this script is complete it moves on to a second ip address and so on with changes made to the file creation?

Any help would be much appreciated.


----------



## TheOutcaste (Aug 8, 2007)

You can rename the files with the Get command, this will also let you add a .txt extension if needed as well.
*Get version "OS Level.txt**"
*
You have to create an separate script for each server, so you can create a folder for each server:, or add the Server name to the file name and use one folder for all the files.
Use one main folder for all, with one folder for each Server you download from, with the 4 subfolders under them, something like this:

```
C:\USERS\THEOUTCASTE\DESKTOP\TEST SCRIPT
&#9492;&#9472;&#9472;&#9472;Test PCC auto log in
    &#9500;&#9472;&#9472;&#9472;PCC1
    &#9500;&#9472;&#9472;&#9472;PCC2
    &#9500;&#9472;&#9472;&#9472;PCC3
    &#9492;&#9472;&#9472;&#9472;PCC4
```
Or add the Server name to the file name and use one folder for all the files.

```
C:\USERS\THEOUTCASTE\DESKTOP\TEST SCRIPT
&#9492;&#9472;&#9472;&#9472;Test PCC auto log in
    &#9492;&#9472;&#9472;&#9472;PCCFiles
```
You'd then have the batch file create the script for each server on the fly, so you would only need one file instead of two.

This will create *Test script\Test PCC auto log in* on the current user's Desktop, then create folders for each server under that folder.
(the *%Userprofile%* variable expands to the current user's profile folder, so it will work on Win2K/XP or Vista later)
Edit the username and password as needed, then enter the folder name (or Server name) and ip address for each server (this shows 4, you can enter any number of servers). You can change the _Local path as well if you don't want it on the Desktop. If you need a different username or password for each Server, that can be done as well.
Edit the Get statements to have the names you want, the names will be the same for each Server, but they will be in different folders.

```
@Echo Off
[COLOR=Red]Set _Username=[USER ID]
Set _Password=[PASSWORD]
Set _Local=%Userprofile%\Desktop\Test script\Test PCC auto log in[/COLOR]
Set _TmpFN1=%temp%\ServerList.tmp
Set _TmpFN2=%temp%\FTPScript.tmp
:: Enter data as FolderName:IPAddress
([COLOR=Red]Echo.PCC1:[IP1]
Echo.PCC2:[IP2]
Echo.PCC3:[IP3]
Echo.PCC4:[IP4][/COLOR])>"%_TmpFN1%"
:::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Do not Edit below this line
:::::::::::::::::::::::::::::::::::::::::::::::::::::
For /F "Tokens=1,2 Delims=:" %%I In ('Type "%_TmpFN1%"') Do (
Call :_MakeScript "%%I" "%%J"
ftp -s:"%_TmpFN2%"
)
If Exist "%_TmpFN1%" Del "%_TmpFN1%"
If Exist "%_TmpFN2%" Del "%_TmpFN2%"
Goto :EOF
Goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                  Subroutines
::::::::::::::::::::::::::::::::::::::::::::::::::::::
:_MakeScript
If Not Exist "%_Local%\%~1" MD "%_Local%\%~1
(Echo.open %~2
Echo.%_Username%
Echo.%_Password%
Echo.binary
Echo.lcd "%_Local%\%~1"
Echo.cd /var/log
[COLOR=Red]Echo.get messages.0 Logfile0.txt
Echo.get messages.1 Logfile1.txt
Echo.get messages.2 Logfile2.txt
Echo.get messages.3 Logfile3.txt
Echo.get messages.4 Logfile4.txt
Echo.get messages.5 Logfile5.txt[/COLOR]
Echo.cd..
Echo.cd..
Echo.cd /etc
[COLOR=Red]Echo.get version "OS Version.txt"[/COLOR]
Echo.cd..
Echo.cd /opt/axiontech/etc
[COLOR=Red]Echo.get version "App Version.txt"[/COLOR]
Echo.cd..
Echo.cd..
Echo.cd..
Echo.cd /var/log/conf
[COLOR=Red]Echo.get modLevel "SN HW.txt"[/COLOR]
Echo.bye)>"%_TmpFN2%"
```
This version uses one folder for all servers, but pre-pends the server name (the *%~1*) to the filename.

So you would have *PCC1-Logfile0.txt, **PCC1-OS Version.txt*, *PCC2-Logfile0.txt, **PCC2-OS Version.txt,* etc, all in the same folder:

```
@Echo Off
[COLOR=Red]Set _Username=[USER ID]
Set _Password=[PASSWORD]
Set _Local=%Userprofile%\Desktop\Test script\Test PCC auto log in[/COLOR]
Set _TmpFN1=%temp%\ServerList.tmp
Set _TmpFN2=%temp%\FTPScript.tmp
:: Enter data as ServerID:IPAddress
([COLOR=Red]Echo.PCC1:[IP1]
Echo.PCC2:[IP2]
Echo.PCC3:[IP3]
Echo.PCC4:[IP4][/COLOR])>"%_TmpFN1%"
:::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Do not Edit below this line
:::::::::::::::::::::::::::::::::::::::::::::::::::::
If Not Exist "%_Local%\%~1" MD "%_Local%\%~1
For /F "Tokens=1,2 Delims=:" %%I In ('Type "%_TmpFN1%"') Do (
Call :_MakeScript "%%I" "%%J"
ftp -s:"%_TmpFN2%"
)
If Exist "%_TmpFN1%" Del "%_TmpFN1%"
If Exist "%_TmpFN2%" Del "%_TmpFN2%"
Goto :EOF
Goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                  Subroutines
::::::::::::::::::::::::::::::::::::::::::::::::::::::
:_MakeScript
(Echo.open %~2
Echo.%_Username%
Echo.%_Password%
Echo.binary
Echo.lcd "%_Local%"
Echo.cd /var/log
[COLOR=Red]Echo.get messages.0 %~1-Logfile0.txt
Echo.get messages.1 %~1-Logfile1.txt
Echo.get messages.2 %~1-Logfile2.txt
Echo.get messages.3 %~1-Logfile3.txt
Echo.get messages.4 %~1-Logfile4.txt
Echo.get messages.5 %~1-Logfile5.txt[/COLOR]
Echo.cd..
Echo.cd..
Echo.cd /etc
[COLOR=Red]Echo.get version "%~1-OS Version.txt"[/COLOR]
Echo.cd..
Echo.cd /opt/axiontech/etc
[COLOR=Red]Echo.get version "%~1-App Version.txt"[/COLOR]
Echo.cd..
Echo.cd..
Echo.cd..
Echo.cd /var/log/conf
[COLOR=Red]Echo.get modLevel "%~1-SN HW.txt"[/COLOR]
Echo.bye)>"%_TmpFN2%"
```


----------



## ve03vsx (Feb 11, 2011)

Hi Outcaste help help help,
I chose the first option and made two seperate files as there are 2 types of device with two differnet file structures. they've both been tested and work fine but... I would like to combine the two by I think making a second sub routine (can I do this?) the two batch files I/You have made are below. The first one I have made some!! notes in


```
@Echo Off
[COLOR=red][B]1 -[/B][/COLOR] Set _Username=user[COLOR=red] - user name has been [B]set[/B] for each use[/COLOR]
[COLOR=red][B]2 -[/B][/COLOR] Set _Password=pass[COLOR=red] - password name has been [B]set[/B] for each use[/COLOR]
[COLOR=red][B]3 -[/B][/COLOR] Set _Local=C:\Documents and Settings\daniel.hall\Desktop\Test script\Test PCC auto log in [COLOR=red]- local dir has been [B]set[/B] for where files are to be made (MD) and transfered too[/COLOR]
[COLOR=red][B]4 -[/B][/COLOR] Set _TmpFN1=%temp%\ServerList.tmp - [COLOR=red]unsure. is _TmpFN1 a command or a made up name? ----  %temp% -- This is the temporary dir my computer -----      \ServerList.tmp - I guess this is a command because the use of the capital L but not sure?[/COLOR]
[COLOR=red][B]5 -[/B][/COLOR] Set _TmpFN2=%temp%\FTPScript.tmp [COLOR=red]---  same but the %temp% is the target device dir and unsure of FTPScript.tmp[/COLOR]
(Echo.PCC1:10.0.0.70
Echo.PCC2:10.0.0.71
Echo.PCC3:10.0.0.72
Echo.PCC4:10.0.0.73)>"%_TmpFN1%"
[B][COLOR=red]6a -[/COLOR][/B] For /F [COLOR=seagreen][B]"Tokens=1,2[/B][/COLOR] Delims=:" %%I In ('Type "%_TmpFN1%"') Do (    --- [COLOR=red]are 6a and b the same line[/COLOR]
[COLOR=red][B]6b - [/B][/COLOR]Call :_MakeScript "%%I" "%%J" [COLOR=red]------ no idea -- yet!! [/COLOR]
ftp -s:"%_TmpFN2%"
)[COLOR=red] - bracket ends here?[/COLOR]
[B][COLOR=red]7 -[/COLOR][/B] If Exist "%_TmpFN1%" Del "%_TmpFN1%" [COLOR=red]- looks like a delete command but am unsure why?[/COLOR]
If Exist "%_TmpFN2%" Del "%_TmpFN2%"
[B][COLOR=red]8 -[/COLOR][/B] Goto :EOF [COLOR=red]----- command means goto End Off F? reminds me of amstrad program commands but not sure of EOF or why its repeated.[/COLOR]
Goto :EOF
[COLOR=red][B]9 -[/B][/COLOR] :_MakeScript [COLOR=red]----- I'm guessing making the sub routine?[/COLOR]
[B][COLOR=red]10 -[/COLOR][/B] If Not Exist "%_Local%\%~1" MD "%_Local%\%~1 [COLOR=red]---O.K were making a dir in the <Set _Local> but the \%~1 I don't no what it means but it must create the file PCC1, but then how does it know hoe to make the next file PPC2 when it runs for the second time[/COLOR]
[B][COLOR=red]11 -[/COLOR][/B] (Echo.open %~2 [COLOR=red]---- what does the open %~2 do? I can't see ~2 in the script anywhere but here.[/COLOR]
Echo.%_Username%
Echo.%_Password%
Echo.binary
Echo.lcd "%_Local%[COLOR=black]\%~1"  ---- [/COLOR][COLOR=green][B]oK this means find local directory which is set by [COLOR=red]line 3[/COLOR] <Set _Local=C:\blah blah> and the %~1 must refer to token 1 - the token bit i'm stuck though[/B][/COLOR]
[COLOR=black]Echo.cd /var/log[/COLOR]
Echo.get messages.0 Logfile0.txt
Echo.get messages.1 Logfile1.txt
Echo.get messages.2 Logfile2.txt
Echo.get messages.3 Logfile3.txt
Echo.get messages.4 Logfile4.txt
Echo.get messages.5 Logfile5.txt
Echo.cd..
Echo.cd..
Echo.cd /etc
Echo.get version "OS Version.txt"
Echo.cd..
Echo.cd /opt/axiontech/etc
Echo.get version "App Version.txt"
Echo.cd..
Echo.cd..
Echo.cd..
Echo.cd /var/log/conf
Echo.get modLevel "SN HW.txt"
[COLOR=red][B]12 -[/B][/COLOR] Echo.bye)>"%_TmpFN2%" ----[COLOR=red] Echo.bye - means end ftp and >"%_TmpFN2%" means start FTP script [/COLOR][COLOR=red]again or this links script to the [B]ftp -s [/B]command?[/COLOR]
```
Not sure if I'm asking the right questions but my aim is to understand the process enough to be able to join the second script as a sub routine of the first by changing the script in blue and adding a third Set _TmpFN3 instruction ?? The *Tokens=1,2 part refers to ~1 as token 1 and ~2 as token 2 am I right*


```
@Echo Off
Set _Username=user 
Set _Password=pass
Set _Local=C:\Documents and Settings\daniel.hall\Desktop\Test script\Display auto log in
[COLOR=blue]Set _TmpFN1=%temp%\ServerList.tmp[/COLOR]
[COLOR=blue]Set _TmpFN2=%temp%\FTPScript.tmp[/COLOR]
(Echo.Car1EFD:10.0.0.140
Echo.Car1ISD1:10.0.0.150
Echo.Car1ISD2:10.0.0.151
Echo.Car1ESD1:10.0.0.170
Echo.Car1ESD2:10.0.0.171
Echo.Car2ISD1:10.0.0.152
Echo.Car2ISD2:10.0.0.153
Echo.Car2ESD1:10.0.0.172
Echo.Car2ESD2:10.0.0.173
Echo.Car3ISD1:10.0.0.154
Echo.Car3ISD2:10.0.0.155
Echo.Car3ESD1:10.0.0.174
Echo.Car3ESD2:10.0.0.175
Echo.Car4EFD:10.0.0.141
Echo.Car4ISD1:10.0.0.156
Echo.Car4ISD2:10.0.0.157
Echo.Car4ISD3:10.0.0.158
Echo.Car4ESD1:10.0.0.176
Echo.Car4ESD2:10.0.0.177
Echo.Car4ESD3:10.0.0.178
Echo.Car4ESD4:10.0.0.179[COLOR=blue])>"%_TmpFN1%"[/COLOR]
[COLOR=blue]For /F "Tokens=1,2 Delims=:" %%I In ('Type "%_TmpFN1%"') Do ([/COLOR]
[COLOR=blue]Call :_MakeScript "%%I" "%%J"[/COLOR]
[COLOR=blue]ftp -s:"%_TmpFN2%"[/COLOR]
[COLOR=blue])[/COLOR]
[COLOR=blue]If Exist "%_TmpFN1%" Del "%_TmpFN1%"[/COLOR]
[COLOR=blue]If Exist "%_TmpFN2%" Del "%_TmpFN2%"[/COLOR]
[COLOR=blue]Goto :EOF[/COLOR]
[COLOR=blue]Goto :EOF[/COLOR]
[COLOR=blue]:_MakeScript[/COLOR]
[COLOR=blue]If Not Exist "%_Local%\%~1" MD "%_Local%\%~1[/COLOR]
[COLOR=blue](Echo.open %~2[/COLOR]
Echo.%_Username%
Echo.%_Password%
Echo.binary
Echo.lcd [COLOR=blue]"%_Local%\%~1"[/COLOR]
Echo.cd /var/log
Echo.get messages.0 Logfile0.txt
Echo.get messages.1 Logfile1.txt
Echo.get messages.2 Logfile2.txt
Echo.get messages.3 Logfile3.txt
Echo.get messages.4 Logfile4.txt
Echo.get messages.5 Logfile5.txt
Echo.cd..
Echo.cd..
Echo.cd /var/tmp
Echo.get version.txt "OS and App Version.txt"
Echo.cd..
Echo.cd..
Echo.cd /var/log
Echo.get modLevel "SN and HW.txt"
Echo.bye[COLOR=blue])>"%_TmpFN2%"[/COLOR]
```


----------



## TheOutcaste (Aug 8, 2007)

The *TmpFN1* and *TmpFN2* variables are just temporary file names. I chose Serverlist.tmp and FTPScript.tmp. You can use File1 and File2, or ListofIPAddresses,txt and ThisIstheFTPScript.txt.
%temp% refers to the users temp folder, located in each users profile folder.
For exampe mine would be this on Vista/Win 7:
*C:\Users\TheOutcaste\AppData\Local\Temp*
and this on Ein2K/XP
*C:\Documents and Settings\TheOutcaste\Local Settings\Temp*

For the For and Call commands, start by opening a Command Prompt and typing *For /?* and *Call /?*.
The Tokens in the For statement have nothing to do with the %~1 and %~2 Batch parameters.
A For statement breaks up a line using the specified delimiters (Delims)
The first piece is called the first token, the 2nd piece is called the 2nd token and so on. There could be dozens of "tokens" in a line.
The *Tokens=1,2* means that the statement will get only the 1st and 2nd token, or piece. The first specified token (1 in this case) is assigned to the loop variable (%%I) . The 2nd specified token (2 in this case) is assigned to the variable that comes after the loop variable (%%J). If there was a third, it would be assigned to %%K
So in this case the first piece is assigned to %%I, the 2nd to %%J.
If you have *Tokens=3,8*. The 3rd piece would be assigned to %%I, the 8th to %%J.

*%~1* refers to the first passed parameter from the Call statement. The *~* means to remove any surrounding quotes. The *%~2* refers to the second parameter passed with the Call statement.
So: 
*Call :_MakeScript "%%I" "%%J"*
%%I is the first parameter, so it will be referenced as %1, %%J is the 2nd, referenced as %2. The fact that they are also the 1st and 2nd token is just a coincidence.

As far as the Command Processor is concerened, this is all one line:

```
For /F "Tokens=1,2 Delims=:" %%I In ('Type "%_TmpFN1%"') Do (
Call :_MakeScript "%%I" "%%J"
ftp -s:"%_TmpFN2%"
)
```
Once the FTP session ends, we delete the two temp files that were created.
The Goto :EOF means goto EndOfFile. Just means quit or exit. If used in a subroutine, meas to exit the subroutine.
It's only needed once, I just didn't notice I'd put it in twice.
The *:_MakeScript* is the label assigned to the subroutine.
We first create the local folder if it doesn't exist. The folder name was passed as the first parameter %1, which is the %%I value read from the Serverlist file.
The %~2 references the 2nd passed parameter, or the %%J value, which is the IP address, so *Open %~2* is *Open 10.0.0.70* the first time through the For loop.

Bye is the exit command for the FTP session.
All of these lines are echoed, and since they are all in parentheses, it's seen as one line. The >"%_TmpFN2%" at the end redirects the output from the screen to the file name in the _TmpFN2 variable.

To combine the two, just make a new ServerList file after the first For loop ends, and the code for the 2nd script as a 2nd subroutine with a differnt name, then just repeat the for loop using that new name:

```
@Echo Off
Set _Username=[USER ID]
Set _Password=[PASSWORD]
Set _Local=%Userprofile%\Desktop\Test script\Test PCC auto log in
Set _TmpFN1=%temp%\ServerList.tmp
Set _TmpFN2=%temp%\FTPScript.tmp
:: Enter data as FolderName:IPAddress
(Echo.PCC1:10.0.0.70
Echo.PCC2:10.0.0.71
Echo.PCC3:10.0.0.72
Echo.PCC4:10.0.0.73)>"%_TmpFN1%"
:::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Do not Edit below this line
:::::::::::::::::::::::::::::::::::::::::::::::::::::
For /F "Tokens=1,2 Delims=:" %%I In ('Type "%_TmpFN1%"') Do (
Call :_MakeScript "%%I" "%%J"
ftp -s:"%_TmpFN2%"
)
[COLOR="Blue"](Echo.Car1EFD:10.0.0.140
Echo.Car1ISD1:10.0.0.150
Echo.Car1ISD2:10.0.0.151
Echo.Car1ESD1:10.0.0.170
Echo.Car1ESD2:10.0.0.171
Echo.Car2ISD1:10.0.0.152
Echo.Car2ISD2:10.0.0.153
Echo.Car2ESD1:10.0.0.172
Echo.Car2ESD2:10.0.0.173
Echo.Car3ISD1:10.0.0.154
Echo.Car3ISD2:10.0.0.155
Echo.Car3ESD1:10.0.0.174
Echo.Car3ESD2:10.0.0.175
Echo.Car4EFD:10.0.0.141
Echo.Car4ISD1:10.0.0.156
Echo.Car4ISD2:10.0.0.157
Echo.Car4ISD3:10.0.0.158
Echo.Car4ESD1:10.0.0.176
Echo.Car4ESD2:10.0.0.177
Echo.Car4ESD3:10.0.0.178
Echo.Car4ESD4:10.0.0.179)>"%_TmpFN1%"
For /F "Tokens=1,2 Delims=:" %%I In ('Type "%_TmpFN1%"') Do (
Call :_MakeScript[B][COLOR="Red"]2[/COLOR][/B] "%%I" "%%J"
ftp -s:"%_TmpFN2%"
)[/COLOR]
If Exist "%_TmpFN1%" Del "%_TmpFN1%"
If Exist "%_TmpFN2%" Del "%_TmpFN2%"
Goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                  Subroutines
::::::::::::::::::::::::::::::::::::::::::::::::::::::
:_MakeScript
If Not Exist "%_Local%\%~1" MD "%_Local%\%~1
(Echo.open %~2
Echo.%_Username%
Echo.%_Password%
Echo.binary
Echo.lcd "%_Local%\%~1"
Echo.cd /var/log
Echo.get messages.0 Logfile0.txt
Echo.get messages.1 Logfile1.txt
Echo.get messages.2 Logfile2.txt
Echo.get messages.3 Logfile3.txt
Echo.get messages.4 Logfile4.txt
Echo.get messages.5 Logfile5.txt
Echo.cd..
Echo.cd..
Echo.cd /etc
Echo.get version "OS Version.txt"
Echo.cd..
Echo.cd /opt/axiontech/etc
Echo.get version "App Version.txt"
Echo.cd..
Echo.cd..
Echo.cd..
Echo.cd /var/log/conf
Echo.get modLevel "SN HW.txt"
Echo.bye)>"%_TmpFN2%"
[COLOR="Blue"]Goto :EOF
:_MakeScript2
If Not Exist "%_Local%\%~1" MD "%_Local%\%~1
(Echo.open %~2
Echo.%_Username%
Echo.%_Password%
Echo.binary
Echo.lcd "%_Local%\%~1"
Echo.cd /var/log
Echo.get messages.0 Logfile0.txt
Echo.get messages.1 Logfile1.txt
Echo.get messages.2 Logfile2.txt
Echo.get messages.3 Logfile3.txt
Echo.get messages.4 Logfile4.txt
Echo.get messages.5 Logfile5.txt
Echo.cd..
Echo.cd..
Echo.cd /var/tmp
Echo.get version.txt "OS and App Version.txt"
Echo.cd..
Echo.cd..
Echo.cd /var/log
Echo.get modLevel "SN and HW.txt"
Echo.bye)>"%_TmpFN2%"[/COLOR]
```


----------



## ve03vsx (Feb 11, 2011)

Hi Outcaste

How do I go about getting the IP and MAC address info from each device and entering it into a .txt file.
Ik now the arp -a command details this info in cmd prompt but I'm not sure if it will work over a local Telnet session and if it does I am struggling to find a way to copy the info into a txt file.

Any help or clues would be a help
thanks
V


----------

