Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP File instead of Copy Command

Status
Not open for further replies.

nayfeh

Programmer
Mar 13, 2002
163
CA
I have a module (see below) that appends to a file if it exisits and creates a new one if it does not.
Since the file is sent to a different server, we're having a lot of issues with regards to user permissions.
I would like to copy the file to a local drive, then FTP to that server instead of copying it directly to that server. Is this possible, and if so, then how?
Your help is appreciated.
Thanks in advance!

Sub AppendToFile(SourceName As String, DestName As String)
Dim SourceHandle As Integer
SourceHandle = FreeFile
Open SourceName For Input As #SourceHandle

Dim DestHandle As Integer
DestHandle = FreeFile
Open DestName For Append As #DestHandle

Do While Not EOF(SourceHandle)
Dim SomeText As String
Line Input #SourceHandle, SomeText
Print #DestHandle, SomeText
Loop

Close #SourceHandle
Close #DestHandle

If Dir(DestName) <> &quot;&quot; Then
Kill SourceName
End If
 
Create a batch file

that calls an ftp script:

here is an example of a ftp script called ftp.txt

open 19.1.20.43 -> machine
anonymous -> login
noone@nowhere.com -> password
ascii -> transfer type ascii
lcd C:\Temp -> local dir where file is located
cd /pub -> directory on other machine
put temp.raw -> transfer file to other machine
bye -> quit

and here is the batch file called ftp_temp.bat

@ECHO OFF
ftp -s:ftp.txt

create a pif file so that it closes automatically after the ftp is done.

and run either RunApp in your module or macro

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top