Home > modtime  [2 examples]

Show last modification time of remote file

 Examples

Ex. 1. fclient_p.remoteModTime usage
Ex. 2. use the following when the remote server doesn't support fclient_p.remoteModTime functionality


Ex. 1.  fclient_p.remoteModTime usage
SET SERVEROUTPUT ON SIZE 1000000;
DECLARE
  fid VARCHAR2(80);
  host VARCHAR2(80)   := 'ftp.gnu.org';
  usernm VARCHAR2(80) := 'anonymous';
  passwd VARCHAR2(80) := '';
  l_local_dt DATE;
  l_remote_dt DATE;
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  fclient_p.remotemodtime(fid, '/README');
  l_remote_dt := TO_DATE(fclient_p.getLastResponseString(fid), 'YYYYMMDDHH24MISS');
  DBMS_OUTPUT.PUT_LINE('remote file: '||TO_CHAR(l_remote_dt, 'DD-MON-YYYY HH24:MI:SS'));

  fclient_p.logout(fid);
  fclient_p.remove(fid);
EXCEPTION
  WHEN fclient_p.java_failed THEN
    DBMS_OUTPUT.PUT_LINE(SUBSTR(fclient_p.getErrorWithResponse(fid), 1, 255));
END;
/

Output: remote file: 10-APR-2003 21:10:19


Ex. 2.  use the following when the remote server doesn't support fclient_p.remoteModTime functionality
SET SERVEROUTPUT ON SIZE 1000000;
SET LINES 255;
DECLARE
  fid VARCHAR2(80);
  host VARCHAR2(80)   := 'ftp.gnu.org';
  usernm VARCHAR2(80) := 'anonymous';
  passwd VARCHAR2(80) := '';
  lv_result VARCHAR2(32767);
  l_list1 fclient_p.list_type;
  l_list2 fclient_p.list_type;
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.listStreamPath(fid, '/README');
  l_list1 := fclient_p.convertDetailListToTables(lv_result);
  FOR i IN 1..l_list1.COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('last modification time: '||l_list1(i).dy||'-'||l_list1(i).mth||'-'||l_list1(i).yr||' '||l_list1(i).tim);
  END LOOP;

  fclient_p.logout(fid);
  fclient_p.remove(fid);
EXCEPTION
  WHEN fclient_p.java_failed THEN
    DBMS_OUTPUT.PUT_LINE(SUBSTR(fclient_p.getErrorWithResponse(fid), 1, 255));
END;
/

Output: last modification time: 15-Apr-2002 00:00

 Related Commands
 ls
 mdir
 newer
 
© 1999-2003 Bear Claw Inc.