Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create ftp script from Directory Listing.

Posted on 2004-10-08
4
Medium Priority
?
188 Views
Last Modified: 2012-08-13
Hi, I am need to do a script file to delete remote files via ftp:

I want to use a directory listing as the base of the text file (called script.txt)
I will shell to a batch file (called logit.bat that does this):

CD "C:\scans\"
dir /B > script.txt

Now say the result of the batch is:

BELLE-16251KTX.TIF
BELLE-16051SCO.TIF
CG-76690BSR.TIF
CG-76690BHB.TIF
OA-2700USR.TIF
OA-2710KTX.TIF

I want to amend this script.txt file to have the necessary commands to delete the files on the remote server.

the end result of the script.txt file would be :

user bco passwd pArtner5
binary
DEL BELLE-16251KTX.TIF
DEL BELLE-16051SCO.TIF
DEL CG-76690BSR.TIF
DEL CG-76690BHB.TIF
DEL OA-2700USR.TIF
DEL OA-2710KTX.TIF
bye

I can handle the rest from here.
So basically i just need to know how to add the following to the top of the file:

user bco passwd pArtner5
binary

The following infront of the already existing lines:
DEL

The following at the very end of the file.
bye



0
Comment
Question by:jerrycsakanyjr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Accepted Solution

by:
naiea1231 earned 2000 total points
ID: 12265878
This will do what you want, written in vbscript so just save it as a .vbs in the same directory as script.txt, it will override the contents of the original file

'open script.txt
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile("script.txt")

Result = "user bco passwd pArtner5" & vbCrLf & "binary"

Do Until oTS.AtEndOfStream
Result = Result & vbCrLf & "DEL " & oTS.ReadLine

Loop

Result = Result & vbCrLf & "bye"

oTS.Close


Set oTS = oFSO.OpenTextFile("script.txt",2)

oTS.Write(Result)

oTS.Close



Let me know how it goes

James
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12266288
You only need the file created?, or you need how to execute it via ftp in VB .NET?
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question