Solved

ftp command line

Posted on 2001-07-25
12
206 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
  • 7
  • 5
12 Comments
 
LVL 2

Expert Comment

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

Author Comment

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

Expert Comment

by:DanielBlais
Comment Utility
And can your application create a txt file somewhere?
0
 
LVL 5

Author Comment

by:arvind
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 5

Author Comment

by:arvind
Comment Utility
could pls give the script or application
0
 
LVL 2

Accepted Solution

by:
DanielBlais earned 200 total points
Comment Utility
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
Comment Utility
could pls give the script or application
0
 
LVL 2

Expert Comment

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

Author Comment

by:arvind
Comment Utility
could pls give the script or application
0
 
LVL 5

Author Comment

by:arvind
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now