Computing.Net > Forums > Programming > Batch File Code Required

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File Code Required

Reply to Message Icon

Name: axeion
Date: August 18, 2009 at 17:47:31 Pacific
OS: Windows xp
Product: Dell / XPS
Subcategory: Batch
Tags: batch, XP, mbox, command prompt, ftp
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: viddywell
Date: August 18, 2009 at 22:13:41 Pacific
Reply:

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


0

Response Number 2
Name: axeion
Date: August 19, 2009 at 06:17:16 Pacific
Reply:

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.


0

Response Number 3
Name: viddywell
Date: August 19, 2009 at 15:04:05 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File Code Required

Tricky Batch File Code? www.computing.net/answers/programming/tricky-batch-file-code/18784.html

FTP batch file www.computing.net/answers/programming/ftp-batch-file/9027.html

need help making a batch file work www.computing.net/answers/programming/need-help-making-a-batch-file-work-/14441.html