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

CDR Data to FTP using Procomm

Status
Not open for further replies.

it44

IS-IT--Management
Jan 25, 2006
56
US
Hi all,

Now that I have the CDR data streaming I have a script that automatically captures and timestamps a file every 24 hours and saves it locally. Does anyone have a script that will allow me to automatically upload that file via ftp to my server every 24 hours? Ive tried numerous routes with no luck, even scheduler. I can get it to connect to the ftp server and open the remote folder, but the send/receive size is 0 and no transfer occurs.

Thanks
 
np ace.

I grabbed it from
Code:
;24HourCapture.WAS     v1.0

;*****************************************************************************
;*                                                                           *
;* 24HourCapture.WAS                                                         *
;* Copyright (C) 1998 Quarterdeck                                            *
;* All rights reserved.                                                      *
;*                                                                           *
;* Written by:  Quarterdeck ASPECT Assist                                    *
;* 06/23/97                                                                  *
;*                                                                           *                                                                             
;* This script file will give the user the option of either capturing data   *
;* in half hour increments, or in 24 hour increments. The Capture file will  *
;* close after a predefined period of inactivity on the port.                *
;*                                                                           *
;* This ASPECT script is intended only as a sample of ASPECT programming.    *
;* Quarterdeck makes no warranty of any kind, express or implied, including  *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*                                                                           *
;* Technical Support is not provided on this script.                         *                                                                          *
;*****************************************************************************



;*************************************************************************
;* MACRO                                                                 *
;*************************************************************************
#define CapFormat 0     ; 0 for 1/2 hour capture file, 1 for 24 hour capture file.
#define FileName 1      ; 0 for fixed name capture file, 1 for time/date file name.
#define CapPath "C:\"   ; Directory for capture files.
#define FixedName "CapFile.CAP"             ;Default set Capture file name.

#define Increment 15    ; Increment in minutes, for specific min. capture file.

#define DialName "Company"     ; The Name of entry to dial back if connection is lost.


;*************************************************************************
;* MAIN                                                                  *
;*************************************************************************
proc main

   when $carrier call DialBack
   set capture path CapPath
   StartProcess()
endproc


;*************************************************************************
;* StartProcess                                                          *
;*************************************************************************
proc StartProcess

   string CapFileName

   while 1
      if FileName                           ;If FileName = 1 set capture to time/date.
         DateName(&CapFileName)
      else
         CapFileName = FixedName            ;Else use set capture name.
      endif
      set capture file CapFileName          ;Set the capture filename for Procomm.
      capture on                            ;Start the capture file.
      if CapFormat                          ;If CapFormat = 1 start 24hr capture.
         Cap24()
      else
         CapHalf()                          ;Else start half hour capture file.
      endif
   endwhile   
endproc


;*************************************************************************
;* DateName                                                              *
;*************************************************************************
proc DateName
param string CapFileName

   string CapTime, CapDate, TempVar1, TempVar2

   TempVar1 = $time24                       ;Get the current time.
   strextract CapTime TempVar1 ":" 0        ;Get hours from time.
   strextract TempVar2 TempVar1 ":" 1       ;Get min. from time.
   strcat CapTime TempVar2                  ;Add min. to hours.
   
   TempVar1 = $date                         ;Get the current date.
   strextract CapDate TempVar1 "/" 0        ;Get month from date.
   strextract TempVar2 TempVar1 "/" 1       ;Get day from date.
   strcat CapDate TempVar2                  ;Add day to month.
   
   CapFileName = CapTime                    ;Set filename to time.
   strcat CapFileName CapDate               ;Add date to filename.
   strcat CapFileName ".CAP"                ;Add '.cap' extension to filename.
endproc


;*************************************************************************
;* Cap24                                                                 *
;*************************************************************************
proc Cap24

   string StopHour, StopMin, TempTime, TempVar, TempVar2
   integer TempInt, IntHour, IntMin
   
   TempTime = $time24                       ;Get the current time.
   strextract StopHour TempTime ":" 0       ;Get hours from time.
   strextract StopMin TempTime ":" 1        ;Get min. from time.


   atoi StopHour IntHour                    ;Convert ASCII hour to integer.
   atoi StopMin IntMin                      ;Convert ASCII minute to integer.

   if IntMin > 0
      IntMin = IntMin - 1
   else
      If IntHour > 0
         IntHour = IntHour - 1
      else
         IntHour = 23
      endif
      IntMin = 59
   endif

   itoa IntHour StopHour                    ;Convert integer hour to ASCII.
   itoa IntMin StopMin                      ;Convert integer minute to ASCII.

   strlen StopHour TempInt 
   if TempInt == 1                        ;If 1 digit number.
      TempVar = StopHour
      StopHour = "0"                      ;Add 0 in front of digit to make it 2 digits.
      strcat StopHour TempVar
   endif

   strlen StopMin TempInt 
   if TempInt == 1                        ;If 1 digit number.
      TempVar = StopMin
      StopMin = "0"                      ;Add 0 in front of digit to make it 2 digits.
      strcat StopMin TempVar
   endif

   strcat StopHour ":"
   strcat StopHour StopMin                  ;Add minutes to hours.

   while 1
      TempTime = $time24                    ;Get the current time.
      strextract TempVar TempTime ":" 0     ;Get hours.
      strextract TempVar2 TempTime ":" 1    ;Get min.
      strcat TempVar ":" 
      strcat TempVar TempVar2               ;Add min. to hours.
      statmsg "Capture file will stop at %s current time is %s" StopHour TempVar
      if strcmp TempVar StopHour            ;If StopTime = Current time.
         waitquiet                          ;Wait for no terminal activity.
         capture off                        ;Close the capture file.
         exitwhile                          ;Exit the while loop.
      else
         yield                              ;Yield processing time.
      endif
   endwhile
endproc   
   

;*************************************************************************
;* CapHalf                                                               *
;*************************************************************************
proc CapHalf

   string StopHour, StopMin, TempTime, TempVar, TempVar2
   integer TempInt, IntMin, IntHour
   
   TempTime = $time24                       ;Get the current time.
   strextract StopHour TempTime ":" 0       ;Get hours from time.
   strextract StopMin TempTime ":" 1        ;Get min. from time.
   atoi StopHour IntHour                    ;Convert ASCII hour to integer.
   atoi StopMin IntMin                      ;Convert ASCII minute to integer.

   IntMin = IntMin + Increment

   if IntMin > 59
      IntMin = IntMin - 60
      if IntHour == 23
         IntHour = 00
      else
         IntHour = IntHour + 1
      endif
   endif

   itoa IntHour StopHour                    ;Convert integer hour to ASCII.
   itoa IntMin StopMin                      ;Convert integer minute to ASCII.

   strlen StopHour TempInt 
   if TempInt == 1                        ;If 1 digit number.
      TempVar = StopHour
      StopHour = "0"                      ;Add 0 in front of digit to make it 2 digits.
      strcat StopHour TempVar
   endif

   strlen StopMin TempInt 
   if TempInt == 1                        ;If 1 digit number.
      TempVar = StopMin
      StopMin = "0"                      ;Add 0 in front of digit to make it 2 digits.
      strcat StopMin TempVar
   endif

   strcat StopHour ":"
   strcat StopHour StopMin                  ;Add minutes to hours.

   while 1
      TempTime = $time24                    ;Get the current time.
      strextract TempVar TempTime ":" 0     ;Get hours.
      strextract TempVar2 TempTime ":" 1    ;Get min.
      strcat TempVar ":" 
      strcat TempVar TempVar2               ;Add min. to hours.
      statmsg "Capture file will stop at %s current time is %s" StopHour TempVar
      if strcmp TempVar StopHour            ;If StopTime = Current time.
         waitquiet                          ;Wait for no terminal activity.
         capture off                        ;Close the capture file.
         exitwhile                          ;Exit the while loop.
      else
         yield                              ;Yield processing time.
      endif
   endwhile
endproc


;*************************************************************************
;* DialBack                                                              *
;*************************************************************************
proc DialBack

   if $carrier == 1
      return
   else
      dial DATA DialName      ; Dial DialName entry.
      while $DIALING          ; Loop while dialing.
      endwhile
      pause 1
      if $CARRIER == 0            ; See if we're connected.
         errormsg "Could not make a connection!"
      else
         
      endif
   endif
   return
endproc
 
here is the captureftp .was that captures live data and ftp's the file. I have the file in the local directory and when the srcipt runs, it connects to the server and sends nothing. Everything appears to be ok with the script...my head hurts

Code:
;CaptureFTP.WAS     v1.0

;*****************************************************************************
;*                                                                           *
;* CaptureFTP.WAS                                                            *
;* Copyright (C) 1998 Quarterdeck                                            *
;* All rights reserved.                                                      *
;*                                                                           *
;* Written by:  Quarterdeck ASPECT Assist                                    *
;* 08/24/98                                                                  *
;*                                                                           *                                                                             
;* This script file captures data to a file from a comm port, and then       *
;* uses the FTP client to send the file to a remote system via FTP           *
;* A time can be specified to start the capture file.                        *
;*                                                                           *
;* This ASPECT script is intended only as a sample of ASPECT programming.    *
;* Quarterdeck makes no warranty of any kind, express or implied, including  *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*                                                                           *
;* Technical Support is not provided on this script.                         *                                                                          *
;*****************************************************************************


;*******************************************************************************
;* Define                                                                      * 
;*******************************************************************************
#define szSTARTTIME "13:16:00"           ;The start time for capture files.
#define szPATH "c:\CDR_Capture"                ;The capture path directory.
#define iQUITTIME 30                     ;The inactivity time to wait for data.
#define szEXT ".cap"                     ;The file extension for cap file.
#define szFTP "ftptransfer"              ;The FTP Connection Directory entry to 
                                         ;upload file

;*******************************************************************************
;* MAIN                                                                        * 
;*******************************************************************************
proc main

   StartProcess()                        ;Call the StartProcess Procedure.
endproc


;*******************************************************************************
;* StartProcess                                                                * 
;*******************************************************************************
proc StartProcess

   string szTime                         ;String variable to hold the system time. 
   
   while 1                               ;Loop forever.
      szTime = $time24                   ;Get the system time in 24 hour format.
      if stricmp szSTARTTIME szTime      ;Compare system time with start time
                                         ;and if they are the same...
         StartIt()                       ;Call the StartIt Procedure.
      else
         yield                           ;Yield processor time while looping.
      endif
   endwhile
endproc


;*******************************************************************************
;* StartIt                                                                     * 
;*******************************************************************************
proc StartIt

   string szFile, szTemp                 ;String variables to hold file names.

   set modem connection 1                ;Set the connection.
   
   strextract szFile $date "/" 0         ;Get the year.
   strextract szTemp $date "/" 1         ;Get the month.
   strcat szFile szTemp                  ;Put year and month together and store
                                         ;it in the szFile variable.
   strextract szTemp $date "/" 2         ;Get the day and put it in szTemp.
   strcat szFile szTemp                  ;Combine the day with the szFile variable
                                         ;and store it back in szFile.
   strcat szFile szEXT                   ;Put the file extension at the end of 
                                         ;the file name stored in szFile.
   
   set capture path szPATH               ;Set the path to store the capture file.
   set capture file szFile               ;Name the capture file with whatever is in
                                         ;the szFile variable.
   capture on                            ;Turn the capture on
   waitquiet iQUITTIME FOREVER           ;Wait for the length of time specified
                                         ;in iQUITTIME.
   capture off                           ;Turn the capture off.
   
   FTPIt(szFile)                         ;Call FTPIt procedure
      
endproc

;*******************************************************************************
;* FTPIt                                                                       * 
;*******************************************************************************

proc FTPIt
param string szFile

   PWMode FTP
   pause 3

   FTP LOCAL CHDIR szPath                      ;Set the local dir. to capture path.
   pause 1
   Connect FTP szFTP                           ;Connect to specified FTP site.
   pause 2
   while $ftpstatus
      yield                                    ;Loop while connecting to FTP site.
   endwhile
   pause 1                                     ;Let Procomm update its screen.
   
   FTP LOCAL COPYFILE szFile                   ;Copy (upload) file to FTP site.
   while $ftpstatus                            ;Yield while transferring file.
      yield
   endwhile
   disconnect
   pause 3
   pwmode TERMINAL
   pause 3
endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top