Saved Bookmarks
| 1. |
Solve : Loop FTP upload file and run again never die.? |
|
Answer» I have this "test_event.log" file from Window and like FTP to Unix server. So I wrote this batch script. The code run ftp worked fine. But I like to keep this batch script loop and run again after 30'. I don't want batch script end. Anyone have any idea how to make this work? Please help....thanks @echo offCode: [Select]@echo off Start /W "C:\PROGRA~2\TEST\OUT" set "file=test_event.log" ( echo open my.host.name echo myusername echo mypassword echo cd "/staging/osdc/dtran" echo binary echo put "%file%" echo close echo quit )> "ftp.txt" :loop ftp -s:"ftp.txt" ping -n 30 localhost >nul goto :loopThanks for the reply...I got the error below after transfer completed. After 30 seconds ftp can override over that file again. Is something wrong here? Please help. Thanks Quote ftp -s:"ftp.txt" Transfers files to and from a computer running an FTP server service (sometimes called a daemon). Ftp can be USED interactively. FTP [-v] [-d] [-i] [-n] [-G] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuf fer] [-b:asyncbuffers] [-w:windowsize] [host] -v Suppresses display of remote server responses. -n Suppresses auto-login upon initial connection. -i Turns off interactive prompting during multiple file transfers. -d Enables debugging. -g Disables filename globbing (see GLOB command). -s:filename Specifies a text file containing FTP commands; the commands will automatically run after FTP starts. -a Use any local interface when binding data connection. -A login as anonymous. -x:send sockbuf Overrides the default SO_SNDBUF size of 8192. -r:recv sockbuf Overrides the default SO_RCVBUF size of 8192. -b:async count Overrides the default async count of 3 -w:windowsize Overrides the default transfer buffer size of 65535. host Specifies the host name or IP address of the remote host to connect to. Notes: - mget and mput commands take y/n/q for yes/no/quit. - Use Control-C to abort commands.The batch file you posted needed the login info changed - did you do that? You SAID the error occurred *after* the transfer succeeded - that is unlikely with the code shown.Thanks...but i checked unix server with command "ls -ltr" didn't see new time stamp every 30 seconds just same file. Seem like didn't loop resend again after 30 seconds. @echo off Start /W "C:\PROGRA~2\TEST\OUT" set "file=test_event.log" ( echo open my.host.name echo myusername echo mypassword echo cd "/staging/osdc/dtran" echo binary echo put "%file%" echo close echo quit )> "ftp.txt" :loop ftp -s:"ftp.txt" ping -n 30 localhost >nul goto :loopThanks Foxidrive. I typo the output somehow. The code worked GREAT. Thanks a lot for ur help.Hi Foxidrive or anyone can help me with this code. I like to apply this code run 4 hours and will (timeout, stop, end...) not loop ftp file again....job will complete. Let say this code start at 9a then 1p will not loop ftp again. I did a lot the tested and can't figure out how to make this work yet. Please help.... . Thanks Quote @echo offQuote from: dtran on April 08, 2013, 11:44:18 AM I like to apply this code run 4 hours and will (timeout, stop, end...) not loop ftp file again....job will complete. Let say this code start at 9a then 1p will not loop ftp again. This line should make it exit when it is 1pm after the last run. The time format in your system might be 12 hour time in which case you will have to change the 13 to 1 for /f "delims=:" %%a in ("%time%") do if %%a EQU 13 goto :EOF See below: Code: [Select]@echo off Start /W "C:\PROGRA~2\TEST\OUT" set "file=test_event.log" ( echo open my.host.name echo myusername echo mypassword echo cd "/staging/osdc/dtran" echo binary echo put "%file%" echo close echo quit )> "ftp.txt" :loop for /f "delims=:" %%a in ("%time%") do if %%a EQU 13 goto :EOF ftp -s:"ftp.txt" ping -n 30 localhost >nul goto :loopAwesome....really nice. Thanks very much for this. |
|