By request.
I'm sure if someone thinks this can be improved, you'll let me know
**********************************************************************************
....Some code to check if winscp.exe exists etc
....some code to check if you've signed up etc
....and some other code

If !Used('WINMAST')
   Select 0
   Use winmast
Endif

Delete File("trbakdone.txt")
mbaks=Alltrim(winkiss.Name)    && the company name that is sending me the
zip file
mbaks=Strtran(mbaks," ","")
mbaks=Strtran(mbaks,"'","")
mbaks=Strtran(mbaks,"-","")

If Day(sysdate)<10
   mbaks=mbaks+"-0"+Alltrim(Str(Day(sysdate)))
Else
   mbaks=mbaks+"-"+Alltrim(Str(Day(sysdate)))
Endif
If Month(sysdate)<10
   mbaks=mbaks+"0"+Alltrim(Str(Month(sysdate)))
Else
   mbaks=mbaks+Alltrim(Str(Month(sysdate)))
Endif
mbaks=mbaks+Alltrim(Str(Year(sysdate)))+"-"
t1=Left(Time(),2)+Substr(Time(),4,2)
mbaks=mbaks+t1
mbaks=mbaks+".ZIP"

openallready=.F.
Select windebs
Do trexchk3 WITH .t.                       && chk if anyone else has the
tables open. It returns openallready status

Close Databases
Set Safety Off

*Delete File tmp*.*
*Delete File tbf*.*
*Delete File ttbf*.*
*Delete File temp*.*

oldfile=mbaks
If File("&oldfile")
   Delete File &oldfile
Endif

_Screen.MousePointer = 11     &&sandglass

* it looks like Winzip is a bitch in this instance so my preference is
azip32. Never failed me yet.
Do trmoment With 'mom '
mbaks="A-"+mbaks
Wait Window Nowait 'Creating backup FILE ('+mbaks+') using Azip32'
tt=azip(.T.,"&mbaks","*.dbf *.fpt windeb500.fr? stat1.fr? windeb810.fr?
-foxuser.* -postcode.* -words*.* -tmp*.* -temp.* -x*.*")
Do trmoment

myxip=''
If File("&mbaks")
   ** create the batch/script file
   b1="option batch on"+Chr(13)
   b2="option confirm off"+Chr(13)

   **Passive mode is special mode of FTP protocol. It is enabled by default.
Disable it only when needed.
   **The option is supported only with FTP protocol.

   If Upper(Curdir())="\PROGS9\WINKISS\" OR athome
      b3="open -passive ftp://myusername:[email protected]:50500
"+Chr(13)
      myxip="192.168.1.14"
   ELSE
      IF !FILE("TRBAKSACTIVE.TXT")                        && read the notes
with Winscp
         b3="open -passive ftp://myusername:[email protected]:50500
"+Chr(13)
      ELSE
         b3="open ftp://myusername:[email protected]:50500"+Chr(13)
      endif
      myxip="203.97.201.237"
   ENDIF

   b4="cd clients"+Chr(13)                                 && the folder on
the FTP server
   b5="option transfer binary"+Chr(13)
   b6="put "+mbaks+Chr(13)
   b7="get -nopreservetime trbakdone.txt" +Chr(13)  &&this is a file I GET
from the server to make sure I had a solid connection
   b8="close"+Chr(13)
   b9="exit"+Chr(13)

   mv9=Strtofile(b1+b2+b3+b4+b5+b6+b7+b8+b9,'TRBAK.TXT')
   *-delete is to delete source   ** put -delete index.html about.html ./

   *******************************************************
   Do trmoment With 'mom'
   IF FILE('SHOWTRBACK.TXT')      && in case I need to see the dos screen
and check whats happening
      Run /N winscp.Exe /Console /script=trbak.txt
   else
      Run /N winscp.Exe /script=trbak.txt  && i dont want to see the black
dos screen to see whats happening
   endif
   *******************************************************

  ** this is ugly and I'm sure someone will comment
   stime=Hour(Datetime())*60+Minute(Datetime())
   xtime=Hour(Datetime())*60+Minute(Datetime())
   etime=stime+30
   mx=0

   Do While .T.
      xtime=Hour(Datetime())*60+Minute(Datetime())
      IF !etime-xtime=mx
         Wait Window Nowait "Transferring to "+myxip+" ........(Max time set
at 30 minutes) "+Str(etime-xtime,10)+" mins sofar"
         mx=etime-xtime
      endif
      If File("trbakdone.txt")
         Exit
      Endif
      If Hour(Datetime())*60+Minute(Datetime())>=etime
         Exit
      Endif
   Enddo
   Wait Clear
   Do trmoment

   timetaken=ALLTRIM(STR(etime-xtime))
   SELECT 0
   USE waudit
   APPEND BLANK
   REPLACE date WITH DATE()
   If File("trbakdone.txt")
      =Messagebox("Your backup has been processed ",0,"Sleep well")
      REPLACE mess WITH "FTP backup was processed at "+TTOC(DATETIME())+"
timed at "+timetaken+" minutes"
   Else
      =Messagebox("Your backup was NOT processed ",0,"Oh dear, please call
Kiss Software")
      REPLACE mess WITH "FTP backup failed at "+TTOC(DATETIME())
   Endif
   CLOSE DATABASES

   Delete File trbak.txt            && so they don't see the batch file and
password etc

   On Shutdown
   Close Data
   Clear Events
   Quit
Endif

Do tropen With .T.
_Screen.MousePointer = 0


-- 
Regards
Sytze de Boer
Kiss Systems


--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to