All Forums >> [Scripting] >> WSH & Client Side VBScript >> Re: Error handling FTP automation Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Hi Zifter, First I would like to thank you for the time you are taking helping me. Here is the script i am using
Now this scripts takes the file from one folder to the backup folder and from the backup folder it uploads it to the ftp server. Since i have scheduled it to do it every night it automaticaly deletes the old file with the new file (on the ftp side). I want the script to take the original file (repsys.mdb) and rename is to repsys+date.mdb and will upload this to the ftp. for example today it will upload repsys300305.mdb and tomorrow i will want it to upload repsys310305.mdb and so on. Is it possible??? If so can you please check my scrip and update it - cause i am a reall noob at it.
First of all, the "Dim" statements are only mandatory if you start your script with "Option Explicit". I think it is good practice to use "Option Explicit" which forces you to declare each variable you use in the script. This way you already prevent type errors with your variables.
Secondly, you don't need to create the FileSystemObject twice (Set objFso = CreateObject("Scripting.FileSystemObject")), once is enough, you can use it until you release it (Set objFso = Nothing)
I added a small piece of code, where the new variables strYear, strMonth and strDay are filled with respectively the current year, month and day.
Finally I changed the "put" command, including the source path of the file to be transferred (so your script doesn't need to be in the same folder as the backup anymore) and concatenating the new variables to the name of the destination file.
I didn't test it, but it should work.
If you still have problems, questions, remarks, ... feel free to post them
After rereading your last post, I think I might have misunderstood exactly what you're trying to do.
The previous script I've posted, will still overwrite the file in the "c:\backup" folder each day. Only the file on the FTP server side will have a name with the current date.
The next script will copy the file to the "c:\backup" folder with the new name (with the date) and then transfer that file to the FTP server. HTH
Thanks Ziffer, I managed to fix it before reading your post, but i will check that script as well. I managed to fix that issue with the winzip function on one of the scripts posted here before. which zips the file with the current date. Thanks alot for the help.
This is my first attempt at creating a vb script. Many thanks to Zifter as I used much of the code he posted. This script "should" download the most current sdat file from ftp.mcafee.com. However, I have two statements that don't work properly. The first is
I've gotten this to work once or twice at the command line also while substituting strControl and strHost for their strings. Sometimes it copies the remote file to a local file named close. Regardless, during the execution of the script, it does nothing more than pop up a dos window with the help for the ftp command displayed.
Thanks in advance to anyone who even takes the time to read this post.
Option Explicit
Dim objFso Dim objShell Dim strInstructions Dim strHost Dim strInstructions2 Dim strInstructions3 Dim strSdatName Dim strControl
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = WScript.CreateObject("WScript.Shell")
For objShell.run "%windir%\system32\findstr.exe /r sdat[0-9] files.txt >" & strSdatName, could you echo everything without objShell.run and paste it here ?
Also, what happens if you replace the above line with:
Thanks Token! You were correct on both suggestions. After a couple other minor additions, the ftp transfer is now successful. For anyone who may be interested in the future, the working script is:
Option Explicit
Dim objFso Dim objShell Dim strInstructions Dim strHost Dim strInstructions2 Dim strInstructions3 Dim strSdatName Dim strControl
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = WScript.CreateObject("WScript.Shell")