Batch File Code Required

August 18, 2009 at 17:47:31
Specs: Windows xp
I need to write a batch file to download files
from MBOX file-share server provided by my
client.

I have written a sample file, that establishes
the connection through my command prompt
to the MBOX file server on the web and list the
directories present.

Here is the code for the mboxscript.bat file :


set PATH=%PATH%;C:\Program Files\Putty
psftp.exe -i "c:\program files\putty\userid-
pri.ppk" userid@mboxnaprd.jnj.com -b
"C:\Data\batch.txt"

Here is the code for the Batch.Txt

dir
bye


This is a sample of the output obtained in the
command prompt.
psftp>
psftp> dir
JANUS_BSS01 JANUS_JANUS
psftp> bye


Now how can I change this code to look for
available files on the server and download
them.

I am an absolute newbie to batch processing.
this is my first batch file till date.

Please help me out.


See More: Batch File Code Required

Report •


#1
August 18, 2009 at 22:13:41
If I understand what you're looking for correctly, I think this may work.

@echo off

REM These can be hardcoded into the below FTP script creation but I left them as prompts for security reasons


Set /P username=FTP Username:
Echo.
Echo.
Set /p pass=FTP Password:


Echo O >>FTPSCRIPT.TMP
Echo ServerNameorAddressHere >>FTPSCRIPT.TMP
Echo %username% >>FTPSCRIPT.TMP
Echo %pass% >>FTPSCRIPT.TMP
Echo bin >>FTPSCRIPT.TMP
Echo CD YourDesiredDirectoryOnTheFTPServer >>FTPSCRIPT.TMP
Echo Prompt >>FTPSCRIPT.TMP
Echo mget * C:\YourLocalDirectoryHere >>FTPSCRIPT.TMP
Echo bye >>FTPSCRIPT.TMP

FTP -s:FTPSCRIPT.TMP

Del /F FTPSCRIPT.TMP
Exit


Report •

#2
August 19, 2009 at 06:17:16
Hi Viddywell,

Looking at what you sent, it seems to be the code i need. But I
am pretty new to batch files, and I am using windows XP
machine and not a Unix System. So can you please send me
the code corresponding to a windows system. I am really sorry
for this.


Report •

#3
August 19, 2009 at 15:04:05
Not a problem - what you're seeing above will run under a windows xp machine.

What you want to do is copy everything from the "@echo off" line to the "Exit" line.

Open notepad

Click File > Save As

change the drop down that says "Save as type" to "All Files"

In the file name save it as whatevernameyoulike.bat. The important part here is adding the .bat portion to the end of the file.

Once you have it saved, you can right click it - choose edit and replace the variables for directories and server name as per your setup.

If you need any further help, please let me know.


Report •

Related Solutions


Ask Question