Computers |
|
| | #1 (permalink) |
| Newb Techie Join Date: Aug 2008
Posts: 1
| Hi, I am trying to write a Windows batch command file to ftp (only upload) some files to a server. But I also need to check if each upload is successful or not and display that information in a log file (only if failed) For that I have created a text file and the following BAT file. I am not exactly sure how to check the status (success/fail) of each upload. Any help would be greatly appreciated. Here is what my .txt file and .bat file looks like. Thanks, FileTransfer.txt myuserid mypassword cd /my/target/directory lcd local lcd uploadfrom binary mput *.gif bye UploadFile.bat @ECHO File upload started at %TIME%>ftp1.log ftp -i -s:FileTransfer.txt myhost>>ftp1.log @ECHO File upload ended at %TIME%>>ftp1.log @echo off if %errorlevel% >= 0 (echo Files upload Failed ) else (echo Files upload Successful) :EOF pause ![]() |
| | |
| | #2 (permalink) |
| honk if you route packets Join Date: Sep 2003
Posts: 4,351
| Well, at some point you are going to have to write within the batch file to cross reference a line of the log file that you are appending to to do "something" if the log file contains certain text like "FAILURE TO UPLOAD" or something like that. So, you can accomplish that in a couple of different ways. You can incorporate a "find" step within your batch file or a "2 step" process that takes the elements of a text file... in this case, a log and then sets it into a variable and then use a IF THEN ELSE against the variable to do a certain task. SET /P ERROR_MESSAGE=<SbxBackup_Folder_Create.txt 2>> SbxBackup_Folder_Create.txt For instance, this is a line in a batch that I did a while ago. I have an error log for a SPECIFIC task in this text file and right before the text file gets deleted, I set the contents of it to the %ERROR_MESSAGE% variable... from there I could echo it, recall it, dump it into another file, test it against an IF THEN ELSE, whatever I want. But first things first, you will need to generate some test logs to find out: 1) What the errors are and when you get them 2) The exact verbiage of the errors These are the key missing elements you need prior to doing anything else.
__________________ A+, Net+, Sec+, Server+, Linux+, MOUS(2000 & '03), MCSE, MCSA, MCT, CNA, CCNA, CCDA, CCNP, CCSP |
| | |
![]() |
| Tags |
| ftp help1 |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need steps for getting rid of SystemDefender.exe | Trotter | Virus - Spyware Protection / Detection | 16 | 04-07-2008 06:57 PM |
| Hijackthis log | jtemple | HijackThis Logs (finished) | 1 | 09-20-2007 08:49 AM |
| Hard Drive Errors!!! Bad or Faulty HDD? | mike4realz | Hardware Troubleshooting | 3 | 09-19-2007 01:56 AM |
| BRL-CAD installation. | zippo | Linux, BSD, other *nixes & Open Source Software | 2 | 06-02-2007 09:11 AM |