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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Files to Remote FTP Location 1

Status
Not open for further replies.

cghoga

Programmer
Jun 26, 2003
614
US
I need help again. Can someone please help?

Honestly I've tried and cannot get this to work.

Yesterday I submitted a post to get files from a remote
FTP location. Knob gave me a script that works great.
I am grateful for that.

Now, I need to be able to transfer files from my local machine to a remote ftp client.
The script would need to copy all the files from a local directory and transfer to the ftp client.

Can someone help?
 
Here's something that I think should do the trick. It doesn't have much in the way of error checking at the moment (not that there is a way to do much error checking with FTP transfers). You'll need to set a value for sLocalPath and may want to modify the value of sFileMask for your purposes.

proc main
integer iStatus ;Integer to hold $FTPCONNECT results
string sLocalPath ;Local path to upload files from
string sRemotePath ;FTP directory to upload to
string sFileMask ;Holds file mask for files to upload
string sConnection ;Connection Directory entry we wish to dial

sLocalPath = "" ;Set path that we want to upload from
sFileMask = "*.*" ;File mask for files to upload
sRemotePath = ""
sConnection = "" ;Connection Directory entry to connect to

ftp local chdir sLocalPath ;Change to local directory containing files to upload
addfilename sLocalPath sFileMask
usermsg "%s" sLocalPath

dial FTP sConnection ;Make connection to FTP site
iStatus = $FTPCONNECT
while (iStatus == 1) ;Wait until connection is established
yield
iStatus = $FTPCONNECT
endwhile
pause 1
switch iStatus
case 3
;Connection attempt failed, perform error handling
endcase
case 2
if not nullstr sRemotePath ;If path on FTP server specified
ftp remote chdir sRemotePath ;Change to that remote directory
endif
if findfirst sLocalPath ;If matching files exist in local directory
ftp local copyfile $FILENAME ;Copy file to FTP site
while $FTPSTATUS ;Loop while file is being copied
yield
endwhile
while findnext ;While more matching files exist
ftp local copyfile $FILENAME
while $FTPSTATUS
yield
endwhile
endwhile
endif
endcase
endswitch
disconnect ;Disconnect from FTP server
endproc

aspect@aspectscripting.com
 
Thank you Knob.

I'll try this in the morning and let you know how it goes.

Thanks again.

Cary
 
Knob, thank you. You are brilliant. It works great!

Is there anyway to verify that the upload was successful, a way to check on the remote ftp side to see if every file that should have been copied over was copied over?

Thanks again.
 
If you look at this script:


you can see how it retrieves the filelist and verifies that the file that was transferred is listed on the remote system. Unfortunately, this only tells you that the transfer started (unless your FTP server does not keep interrupted transfers), since there is no way in ASPECT that I am aware of to detect that the file copy failed. The method in the script works for just one file, so you'll need to either check the file listing after each transfer, or save the list of files you intend to transfer to a text file and compare that list of files to the list from the FTP server.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top