 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
Glenn Bennett
Joined: 23 Oct 2003 Posts: 3
|
|
FTPFileSize and FTPFileDateTime |
|
I am sending files from a local server through FTP to a remote server with an FTPPut command. The name of the server, user id and password are all variables I use when doing the FTPPUT, FTPFileSize or FTPFileDateTIme commands. The put works fine but for the filesize I get back 0 in my return number. Similarly, when I do the FTPFileDateTIme, I get back 1/1/1980 12:00. When I go in through DOS, I can see the filesize and time so I don't believe it is a rights issue. I want to do this to validate the entire file has been FTP'd to the remote server. Is there anything I can do differently? Can you help?
|
|
Thu Oct 23, 2003 2:20 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7969
|
|
Re: FTPFileSize and FTPFileDateTime |
|
How are these variables declared in the script? Did you set the right data type? : I am sending files from a local server through FTP to a remote server with an : FTPPut command. The name of the server, user id and password are all : variables I use when doing the FTPPUT, FTPFileSize or FTPFileDateTIme : commands. The put works fine but for the filesize I get back 0 in my : return number. Similarly, when I do the FTPFileDateTIme, I get back : 1/1/1980 12:00. When I go in through DOS, I can see the filesize and time : so I don't believe it is a rights issue. I want to do this to validate the : entire file has been FTP'd to the remote server. Is there anything I can : do differently? Can you help?
|
|
Thu Oct 23, 2003 3:47 pm |
|
 |
Glenn Bennett
Joined: 23 Oct 2003 Posts: 3
|
|
Re: FTPFileSize and FTPFileDateTime |
|
: How are these variables declared in the script? : Did you set the right data type? Server, userid and password are all strings FTPFileSize returns to number variable FTPFileDateTime returns to datetime variable Used FileSize on local machine for compare value to number variable Used FileDate on local as date variable and FileTime on local as time, then used concat to create datetime variable for compare All variables are declared through Dim statements I think I did the right data type but it's not working so maybe not. Thanks
|
|
Thu Oct 23, 2003 4:38 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7969
|
|
Re: FTPFileSize and FTPFileDateTime |
|
Can you post your script please? You can remove or replace any sensitive parts like user id, server, and password with some dummy values. Please also let us know what type of FTP server software you use and on which operation system you run it. : Server, userid and password are all strings : FTPFileSize returns to number variable : FTPFileDateTime returns to datetime variable : Used FileSize on local machine for compare value to number variable : Used FileDate on local as date variable and FileTime on local as time, then : used concat to create datetime variable for compare : All variables are declared through Dim statements : I think I did the right data type but it's not working so maybe not. Thanks
|
|
Thu Oct 23, 2003 5:15 pm |
|
 |
Glenn Bennett
Joined: 23 Oct 2003 Posts: 3
|
|
Re: FTPFileSize and FTPFileDateTime |
|
: Can you post your script please? You can remove or replace any sensitive : parts like user id, server, and password with some dummy values. : Please also let us know what type of FTP server software you use and on which : operation system you run it. :Listed below is the script. There are two remote servers. The first is a Win2000 OS running Novell 5.0 as the NOS :The second remote server and the one I am trying to get size and date from is a DEC Alpha 4100 running OpenVMS v7.3, Compaq TCPIP Services for Alpha v5.1 :Thanks again for your help //Declare variables for movefile_name, dest_dir(for novell destination directory), source_dir(for addvantage directory Dim file_line, string Dim write_line, string Dim write_line2, string Dim file_name, string Dim movefile_name, string Dim movefile, string Dim filemove_list, string,"h:\\trp\\extract\\filesmoved_" Dim errormove_list, string,"h:\\trp\\extract\\moveerrors_" Dim dest_dir, string Dim dest_dir_back, string Dim source_dir, string Dim acctg_dir, string,"//server/users/workgrps/" Dim acctg_dir_back, string,"//server\\users\\workgrps\\" Dim systems_dir, string,"//server/users/workgrps/systems/" Dim alpha_dir, string, "dkc101:[addv_extracts]" Dim ftpserver, string, "remoteserver1" Dim ftpid, string, "remoteid1" Dim ftppass, string, "remotepassword1" Dim ftpserver2, string, "remoteserver2" Dim ftpid2, string, "remoteid2" Dim ftppass2, string, "remotepassword2" Dim norw_dir, string Dim month_txt, string Dim day_txt, string Dim year_txt, string Dim today_txt, string Dim norw, boolean Dim not_found, boolean Dim end_of_file, boolean Dim size_error, boolean Dim errors_exist, boolean Dim movefile_size, number Dim sendfile_size, number Dim file_num, number Dim file_num2, number Dim file_num3, number Dim numreturn, number Dim numfound, number, 0 Dim movecount, number, 0 Dim month, number Dim day, number Dim year, number Dim today, date Dim movefile_date, datetime Dim sendfile_date, date Dim sendfile_time, time Dim sendfile_datetime, datetime //Creates variable of mmddyyyy of today's date Today(today) DateTimePart(today, "mm", month) Format( month, "00", month_txt ) DateTimePart(today, "dd", day) Format(day,"00", day_txt) DatetimePart(today, "yy", year) Format(year,"0000",year_txt) ConcatEx(month_txt,day_txt,year_txt,today_txt) //Open tab-delimited file of destination directory, movefile_name and source directory, create filename for list of movefiles, move errors FileOpen( "n:\dbases\data\addvantage-novell_move.txt", "LineMode", "Read", False, file_num ) ConcatEx(filemove_list,today_txt,".txt",filemove_list) ConcatEx(errormove_list,today_txt,".txt",errormove_list) //Begin Read Loop EOF( file_num, end_of_file ) LoopUntil( end_of_file, END_LOOP ) // Read in each line and split tabs into destination directory, movefile_name and source directory FileRead( file_num, file_line ) GetToken( "\t", file_line, dest_dir ) GetToken( "\t", file_line, movefile_name ) GetToken( "\t",file_line,source_dir) Left(dest_dir,1,norw_dir) Set(movefile, movefile_name) //Set Branch boolean according to w: or n: drives isequal(norw_dir,"w",norw) //Branches based on destintation directory (w:\(Acctg) or n:\(systems) drives), then issues FTP Put Command If(norw,ACCTG,SYSTEMS) //FTP Login defaults to w:\accounting, 1st concat adds full UNC path and text filename for destination file //2nd concat adds drive mapping path plus text filename for source file, check made for file existance //If not found, gets next record ACCTG: Mid(dest_dir,4,30,norw_dir) ConcatEx(acctg_dir,norw_dir,"/",movefile_name,dest_dir) ConcatEx(acctg_dir_back,norw_dir,"\\",movefile_name,dest_dir_back) ConcatEx(source_dir,"\\",movefile_name,movefile_name) ConcatEx(alpha_dir,movefile, movefile) NotFileExists( movefile_name, not_found ) Ifthen(not_found, GET_NEXT) //Records file attributes, then writes entry for file moved with filename and attributes, comma-delimited FileDate( movefile_name, sendfile_date ) FileTime( movefile_name, sendfile_time ) FileSize( movefile_name, sendfile_size ) FileOpen( filemove_list, "LineMode", "Write", True , file_num2 ) Concatex( movefile_name,",",sendfile_date,",",sendfile_time,",",sendfile_size,write_line) FileWrite( file_num2, write_line ) FileClose (file_num2) DateTime( sendfile_date, sendfile_time, sendfile_datetime ) //Send file from Addvantage to Novell FTPConfig( "Transfer Mode", "ASCII" ) FTPConfig( "Preserve File Times", "True") FTPPutFile( ftpserver, ftpid, ftppass, movefile_name, dest_dir ) //Send Archive copy to the Alpha FTPConfig( "Transfer Mode", "ASCII" ) FTPConfig( "Preserve File Times", "True") FTPPutFile( ftpserver2, ftpid2, ftppass2, movefile_name, movefile ) FTPFileSize( ftpserver2, ftpid2, ftppass2, movefile, movefile_size ) FTPFileDateTime( ftpserver2, ftpid2, ftppass2, movefile, movefile_date ) GoTo( CHECK_ERRORS) //FTP Login defaults to w:\accounting, 1st concat adds full UNC path and text filename for destination file //2nd concat adds drive mapping path plus text filename for source file, check made for file existance //If not found, gets next record SYSTEMS: Mid(dest_dir,4,30,norw_dir) ConcatEx(systems_dir,norw_dir,"/",movefile_name,dest_dir) ConcatEx(source_dir,"\\",movefile_name,movefile_name) ConcatEx(alpha_dir,movefile, movefile) NotFileExists( movefile_name, not_found ) Ifthen(not_found, GET_NEXT) //Records file attributes, then writes entry for file moved with filename and attributes, comma-delimited FileDate( movefile_name, sendfile_date ) FileTime( movefile_name, sendfile_time ) FileSize( movefile_name, sendfile_size ) FileOpen( filemove_list, "LineMode", "Write", True , file_num2 ) Concatex( movefile_name,",",sendfile_date,",",sendfile_time,",",sendfile_size,write_line) FileWrite( file_num2, write_line ) FileClose (file_num2) DateTime( sendfile_date, sendfile_time, sendfile_datetime ) //Send file from Addvantage to Novell FTPConfig( "Transfer Mode", "ASCII" ) FTPConfig( "Preserve File Times", "True") FTPPutFile( ftpserver, ftpid, ftppass, movefile_name, dest_dir ) //Send Archive copy to the Alpha FTPConfig( "Transfer Mode", "ASCII" ) FTPConfig( "Preserve File Times", "True") FTPPutFile( ftpserver2, ftpid2, ftppass2, movefile_name, movefile ) FTPFileSize( ftpserver2, ftpid2, ftppass2, movefile, movefile_size ) FTPFileDateTime( ftpserver2, ftpid2, ftppass2, movefile, movefile_date ) //Check for filesize errors from move, create error file if sizes don't match CHECK_ERRORS: notequal(movefile_size, sendfile_size, size_error) If( size_error, ERROR_FILE, GET_NEXT ) ERROR_FILE: FileOpen(errormove_list, "LineMode", "Write", True , file_num3 ) ConcatEx( movefile_name," had an FTP error. ",sendfile_size," sent and ",movefile_size," received. Please investigate and manually transfer if necessary",write_line2) FileWrite(file_num3,write_line2) FileClose( file_num3) GET_NEXT: EOF( file_num, end_of_file ) END_LOOP: FileExists( errormove_list, errors_exist ) if(errors_exist,MAIL_SEND,END_PROG) MAIL_SEND: MailSendWithAttachment( "24x7ftpaddvtonovell", "", "glenn.bennett@huntington.com", "FTP Errors", "Please see the attachment for FTP errors when sending files to Alpha for archive", errormove_list ) END_PROG: FileClose (file_num)
|
|
Fri Oct 24, 2003 8:45 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7969
|
|
Re: FTPFileSize and FTPFileDateTime |
|
I have good and bad news for you. The good news is that in the event FTPPutFile fails the entire job fails automatically so that you do not need to verify file size or time. 24x7 takes care of the error handling. The bad news is that FTP protocol lacks native methods for obtaining files size and date. The way it works in 24x7, it calls certain operation system functions to execute remote "dir" or "ls" command (depends on the FTP host operation system) which then parse the returned text output. Old DEC systems (as well as old HP-UX) return non-common output inconsistent with other UNIX systems and as a result it may cause the parsing to be incorrect. If you run Windows version with Internet Explorer 5.5 or earlier installed on the computer with 24x7 try upgrading Internet Explorer to version 6 SP1. This might fix the issue with the size and date/time parsing. Also your DEC FTP server probably does not support FTPConfig( "Preserve File Times", "True") . You may want to enable tracing in 24x7 (Tools/Options menu, Log page) and re-run the job to verify results of internal "set file time" operations. : //Declare variables for movefile_name, dest_dir(for novell destination : directory), source_dir(for addvantage directory : Dim file_line, string : Dim write_line, string : Dim write_line2, string : Dim file_name, string : Dim movefile_name, string : Dim movefile, string : Dim filemove_list, string,"h:\\trp\\extract\\filesmoved_" : Dim errormove_list, string,"h:\\trp\\extract\\moveerrors_" : Dim dest_dir, string : Dim dest_dir_back, string : Dim source_dir, string : Dim acctg_dir, string,"//server/users/workgrps/" : Dim acctg_dir_back, string,"//server\\users\\workgrps\\" : Dim systems_dir, string,"//server/users/workgrps/systems/" : Dim alpha_dir, string, "dkc101:[addv_extracts]" : Dim ftpserver, string, "remoteserver1" : Dim ftpid, string, "remoteid1" : Dim ftppass, string, "remotepassword1" : Dim ftpserver2, string, "remoteserver2" : Dim ftpid2, string, "remoteid2" : Dim ftppass2, string, "remotepassword2" : Dim norw_dir, string : Dim month_txt, string : Dim day_txt, string : Dim year_txt, string : Dim today_txt, string : Dim norw, boolean : Dim not_found, boolean : Dim end_of_file, boolean : Dim size_error, boolean : Dim errors_exist, boolean : Dim movefile_size, number : Dim sendfile_size, number : Dim file_num, number : Dim file_num2, number : Dim file_num3, number : Dim numreturn, number : Dim numfound, number, 0 : Dim movecount, number, 0 : Dim month, number : Dim day, number : Dim year, number : Dim today, date : Dim movefile_date, datetime : Dim sendfile_date, date : Dim sendfile_time, time : Dim sendfile_datetime, datetime : //Creates variable of mmddyyyy of today's date : Today(today) : DateTimePart(today, "mm", month) : Format( month, "00", month_txt ) : DateTimePart(today, "dd", day) : Format(day,"00", day_txt) : DatetimePart(today, "yy", year) : Format(year,"0000",year_txt) : ConcatEx(month_txt,day_txt,year_txt,today_txt) : //Open tab-delimited file of destination directory, movefile_name and source : directory, create filename for list of movefiles, move errors : FileOpen( "n:\dbases\data\addvantage-novell_move.txt", : "LineMode", "Read", False, file_num ) : ConcatEx(filemove_list,today_txt,".txt",filemove_list) : ConcatEx(errormove_list,today_txt,".txt",errormove_list) : //Begin Read Loop : EOF( file_num, end_of_file ) : LoopUntil( end_of_file, END_LOOP ) : // Read in each line and split tabs into destination directory, movefile_name : and source directory : FileRead( file_num, file_line ) : GetToken( "\t", file_line, dest_dir ) : GetToken( "\t", file_line, movefile_name ) : GetToken( "\t",file_line,source_dir) : Left(dest_dir,1,norw_dir) : Set(movefile, movefile_name) : //Set Branch boolean according to w: or n: drives : isequal(norw_dir,"w",norw) : //Branches based on destintation directory (w:\(Acctg) or n:\(systems) : drives), then issues FTP Put Command : If(norw,ACCTG,SYSTEMS) : //FTP Login defaults to w:\accounting, 1st concat adds full UNC path and text : filename for destination file : //2nd concat adds drive mapping path plus text filename for source file, : check made for file existance : //If not found, gets next record : ACCTG: Mid(dest_dir,4,30,norw_dir) : ConcatEx(acctg_dir,norw_dir,"/",movefile_name,dest_dir) : ConcatEx(acctg_dir_back,norw_dir,"\\",movefile_name,dest_dir_back) : ConcatEx(source_dir,"\\",movefile_name,movefile_name) : ConcatEx(alpha_dir,movefile, movefile) : NotFileExists( movefile_name, not_found ) : Ifthen(not_found, GET_NEXT) : //Records file attributes, then writes entry for file moved with filename and : attributes, comma-delimited : FileDate( movefile_name, sendfile_date ) : FileTime( movefile_name, sendfile_time ) : FileSize( movefile_name, sendfile_size ) : FileOpen( filemove_list, "LineMode", "Write", True , : file_num2 ) : Concatex( : movefile_name,",",sendfile_date,",",sendfile_time,",",sendfile_size,write_line) : FileWrite( file_num2, write_line ) : FileClose (file_num2) : DateTime( sendfile_date, sendfile_time, sendfile_datetime ) : //Send file from Addvantage to Novell : FTPConfig( "Transfer Mode", "ASCII" ) : FTPConfig( "Preserve File Times", "True") : FTPPutFile( ftpserver, ftpid, ftppass, movefile_name, dest_dir ) : //Send Archive copy to the Alpha : FTPConfig( "Transfer Mode", "ASCII" ) : FTPConfig( "Preserve File Times", "True") : FTPPutFile( ftpserver2, ftpid2, ftppass2, movefile_name, movefile ) : FTPFileSize( ftpserver2, ftpid2, ftppass2, movefile, movefile_size ) : FTPFileDateTime( ftpserver2, ftpid2, ftppass2, movefile, movefile_date ) : GoTo( CHECK_ERRORS) : //FTP Login defaults to w:\accounting, 1st concat adds full UNC path and text : filename for destination file : //2nd concat adds drive mapping path plus text filename for source file, : check made for file existance : //If not found, gets next record : SYSTEMS: Mid(dest_dir,4,30,norw_dir) : ConcatEx(systems_dir,norw_dir,"/",movefile_name,dest_dir) : ConcatEx(source_dir,"\\",movefile_name,movefile_name) : ConcatEx(alpha_dir,movefile, movefile) : NotFileExists( movefile_name, not_found ) : Ifthen(not_found, GET_NEXT) : //Records file attributes, then writes entry for file moved with filename and : attributes, comma-delimited : FileDate( movefile_name, sendfile_date ) : FileTime( movefile_name, sendfile_time ) : FileSize( movefile_name, sendfile_size ) : FileOpen( filemove_list, "LineMode", "Write", True , : file_num2 ) : Concatex( : movefile_name,",",sendfile_date,",",sendfile_time,",",sendfile_size,write_line) : FileWrite( file_num2, write_line ) : FileClose (file_num2) : DateTime( sendfile_date , sendfile_time, sendfile_datetime ) : //Send file from Addvantage to Novell : FTPConfig( "Transfer Mode", "ASCII" ) : FTPConfig( "Preserve File Times", "True") : FTPPutFile( ftpserver, ftpid, ftppass, movefile_name, dest_dir ) : //Send Archive copy to the Alpha : FTPConfig( "Transfer Mode", "ASCII" ) : FTPConfig( "Preserve File Times", "True") : FTPPutFile( ftpserver2, ftpid2, ftppass2, movefile_name, movefile ) : FTPFileSize( ftpserver2, ftpid2, ftppass2, movefile, movefile_size ) : FTPFileDateTime( ftpserver2, ftpid2, ftppass2, movefile, movefile_date ) : //Check for filesize errors from move, create error file if sizes don't match : CHECK_ERRORS: notequal(movefile_size, sendfile_size, size_error) : If( size_error, ERROR_FILE, GET_NEXT ) : ERROR_FILE: FileOpen(errormove_list, "LineMode", "Write", : True , file_num3 ) : ConcatEx( movefile_name," had an FTP error. ",sendfile_size," : sent and ",movefile_size," received. Please investigate and : manually transfer if necessary",write_line2) : FileWrite(file_num3,write_line2) : FileClose( file_num3) : GET_NEXT: EOF( file_num, end_of_file ) : END_LOOP: FileExists( errormove_list, errors_exist ) : if(errors_exist,MAIL_SEND,END_PROG) : MAIL_SEND: MailSendWithAttachment( "24x7ftpaddvtonovell", : "", "glenn.bennett@huntington.com", "FTP : Errors", "Please see the attachment for FTP errors when sending : files to Alpha for archive", errormove_list ) : END_PROG: FileClose (file_num)
|
|
Fri Oct 24, 2003 9:36 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|