Solved

ftp command line

Posted on 2001-07-25
12
214 Views
Last Modified: 2010-04-13
I want to create a batch file - which will transfer a directory to another machine using ftp command.

cud anybody help me

0
Comment
Question by:arvind
[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
  • 7
  • 5
12 Comments
 
LVL 2

Expert Comment

by:DanielBlais
ID: 6317681
Do you know the content of the directory, or the content is it subject to change?
0
 
LVL 5

Author Comment

by:arvind
ID: 6317690
no - sql store procedure will create random sub-dir in that directory.
0
 
LVL 2

Expert Comment

by:DanielBlais
ID: 6317752
And can your application create a txt file somewhere?
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 5

Author Comment

by:arvind
ID: 6317769
Hi  DanielBlais ,

Basic need are following

machine1 -- c:\partner
--part1
--part2
--wdjjkd
--1289613

machine2 --c:\partner

So I like to copy partner direcorty to machine2 with all the contains.

0
 
LVL 2

Expert Comment

by:DanielBlais
ID: 6317807
You'll need an application that recurse the directory and write an txt files which contain the ftp command.
0
 
LVL 5

Author Comment

by:arvind
ID: 6317844
Hi  DanielBlais ,

Basic need are following

machine1 -- c:\partner
--part1
--part2
--wdjjkd
--1289613

machine2 --c:\partner

So I like to copy partner direcorty to machine2 with all the contains.

0
 
LVL 5

Author Comment

by:arvind
ID: 6317847
could pls give the script or application
0
 
LVL 2

Accepted Solution

by:
DanielBlais earned 200 total points
ID: 6317988
Here the vb application that generate the batch files.

Run UPLOAD.BAT

Change the parameter for your settings.

You may need to change a bit as per your need.

Option Explicit
Dim sFich() As String
Dim iNbFich As Long
Dim iNbDir As Long
Const servername = "1.1.1.1"
Const username = "username"
Const password = "password"

Private Sub main()
searchFile "d:\projets"
Dim i As Long

Open "c:\ftpup\upload.bat" For Output As #1
For i = 1 To iNbDir
Print #1, "call ftp" & i & ".bat"
Next i
Close #1

End Sub


Public Sub searchFile(sHomeDir As String)
Dim sTempFich As String

Dim iNbRep As Integer         ' Le nombre de repertoire dans le repertoire courrant
Dim sRep() As String          ' Le array des repertoires dans le rep courrant
Dim i As Integer

' Stock (variable globale) les fichiers trouves dans le rep courrant
sTempFich = Dir(sHomeDir + "\*.*")
iNbDir = iNbDir + 1

Open "c:\ftpup\ftp" & CStr(iNbDir) & ".bat" For Output As #1
Print #1, Left(sHomeDir, 2)
Print #1, "cd" & Right(sHomeDir, Len(sHomeDir) - 2)
Print #1, "ftp " & servername & " -s:c:\ftpup\dir" & iNbDir
Close #1

Open "c:\ftpup\dir" & CStr(iNbDir) For Output As #1

Print #1, username
Print #1, password
Print #1, "other ftp command ... "
Print #1, "cd" & Right(sHomeDir, Len(sHomeDir) - 2)

While sTempFich <> ""
    If sTempFich <> "." And sTempFich <> ".." Then
        If GetAttr(sHomeDir + "\" + sTempFich) <> vbDirectory Then
            Print #1, "put " & sTempFich
        End If
    End If

    sTempFich = Dir
Wend

Close #1

' stock (variable locale) tous les repertoires dans le rep courant
sTempFich = Dir(sHomeDir + "\*.*", vbDirectory)
While sTempFich <> ""
    If sTempFich <> "." And sTempFich <> ".." Then
        If GetAttr(sHomeDir + "\" + sTempFich) = vbDirectory Then
            iNbRep = iNbRep + 1
            ReDim Preserve sRep(iNbRep - 1)
            sRep(iNbRep - 1) = sHomeDir + "\" + sTempFich
        End If
    End If
 
    sTempFich = Dir
Wend

' cherche dans tous les repertoires trouves
For i = 0 To iNbRep - 1
    searchFile sRep(i)
Next i
End Sub


0
 
LVL 5

Author Comment

by:arvind
ID: 6318042
could pls give the script or application
0
 
LVL 2

Expert Comment

by:DanielBlais
ID: 6318053
Don't make an refresh after posting an comment, il make your comment post twice!
0
 
LVL 5

Author Comment

by:arvind
ID: 6318091
could pls give the script or application
0
 
LVL 5

Author Comment

by:arvind
ID: 6350433
Thanks - I'd made some mdoification in ur script - Its now working fine. But Whenever new folder comed we need to run script agagin.

And this script does not create folder - this means 1st time I'd copy folder manualy
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Make the most of your online learning experience.
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

696 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