Home > ls  [18 examples]

List contents of remote directory.

 Examples

Ex. 1. listing with details in the current remote directory
Ex. 2. listing without details in the current remote directory
Ex. 3. display listing with details in the current remote directory
Ex. 4. display listing without details in the current remote directory
Ex. 5. listing for a single file with details
Ex. 6. listing for a single file without details
Ex. 7. display a listing for a single file with details
Ex. 8. display a listing for a single file without details
Ex. 9. listing for a directory with details
Ex. 10. listing for a directory without details
Ex. 11. display a listing for a directory with details
Ex. 12. display a listing for a directory without details
Ex. 13. extract the details for a listing of the current remote directory into a PL/SQL Table
Ex. 14. extract the details for a listing of file names from the current remote directory into a PL/SQL Table
Ex. 15. extract the details for a listing of a single file into a PL/SQL Table
Ex. 16. extract the details for a listing of the file name from a single file into a PL/SQL Table
Ex. 17. extract the details for a directory listing into a PL/SQL Table
Ex. 18. extract the details for a listing of file names for a directory listing into a PL/SQL Table


Ex. 1.  listing with details in the current remote directory
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.listStream(fid);
  DBMS_OUTPUT.PUT_LINE(SUBSTR(lv_result, 1, 255));

  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: lrwxrwxrwx 1 0 101 15 Mar 22 18:13 FTP-Mirrors -> gnu/GNUinfo/FTP -rw-rw-r-- 1 100 101 2103 Aug 16 2002 README -rw-rw-r-- 1 0 101 1516 Aug 18 2000 README.~1~ drwxr-sr-x 2 0 101


Ex. 2.  listing without details in the current remote directory
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.nameListStream(fid);
  DBMS_OUTPUT.PUT_LINE(SUBSTR(lv_result, 1, 255));

  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: FTP-Mirrors README README.~1~ bbc find-ls.txt find-ls.txt.asc find-ls.txt.gz find-ls.txt.gz.asc gnu html index.html iso lpf.README ls-lrR.txt ls-lrR.txt.asc ls-lrR.txt.gz ls-lrR.txt.gz.asc md5sums.txt md5sums.txt.asc md5sums.txt.gz md5


Ex. 3.  display listing with details in the current remote directory
EXECUTE DBMS_JAVA.SET_OUTPUT(1000000);
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  fclient_p.displayListStream(fid);

  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: lrwxrwxrwx 1 0 101 15 Mar 22 18:13 FTP-Mirrors -> gnu/GNUinfo/FTP -rw-rw-r-- 1 100 101 2103 Aug 16 2002 README -rw-rw-r-- 1 0 101 1516 Aug 18 2000 README.~1~ drwxr-sr-x 2 0 101 4096 Jan 21 16:56 bbc -rw-rw-r-- 1 100 101 3956905 Apr 09 06:22 find-ls.txt -rw-r--r-- 1 1225 1225 232 Apr 09 06:22 find-ls.txt.asc -rw-rw-r-- 1 100 101 379567 Apr 09 06:22 find-ls.txt.gz -rw-r--r-- 1 1225 1225 232 Apr 09 06:22 find-ls.txt.gz.asc drwxrwsr-x 226 0 101 8192 Mar 22 17:59 gnu drwxr-sr-x 2 0 101 4096 Mar 22 18:13 html -rw-rw-rw- 1 0 101 7470 Apr 09 06:25 index.html drwxrwsr-x 11 0 101 4096 Mar 22 18:11 iso -r--rw-r-- 1 0 101 90 Feb 16 1993 lpf.README -rw-r--r-- 1 1225 101 2326213 Apr 09 06:22 ls-lrR.txt -rw-r--r-- 1 1225 1225 232 Apr 09 06:22 ls-lrR.txt.asc -rw-r--r-- 1 1225 101 249825 Apr 09 06:22 ls-lrR.txt.gz -rw-r--r-- 1 1225 1225 232 Apr 09 06:22 ls-lrR.txt.gz.asc -rw-rw-r-- 1 100 101 2297992 Apr 09 06:22 md5sums.txt -rw-r--r-- 1 1225 1225 232 Apr 09 06:22 md5sums.txt.asc -rw-rw-r-- 1 100 101 630269 Apr 09 06:22 md5sums.txt.gz -rw-r--r-- 1 1225 1225 232 Apr 09 06:22 md5sums.txt.gz.asc lrwxrwxrwx 1 0 0 11 Mar 22 17:52 non-gnu -> gnu/non-gnu drwxrwsr-x 26 0 101 4096 Mar 22 17:52 old-gnu lrwxrwxrwx 1 0 0 1 Mar 22 17:52 pub -> . -rw-r--r-- 1 1225 101 2499328 Apr 09 06:22 sha1sums.txt -rw-r--r-- 1 1225 101 232 Apr 09 06:22 sha1sums.txt.asc -rw-r--r-- 1 1225 101 748871 Apr 09 06:22 sha1sums.txt.gz -rw-r--r-- 1 1225 101 232 Apr 09 06:22 sha1sums.txt.gz.asc drwxrwsr-x 2 100 101 4096 Mar 22 17:59 third-party -rw-rw-r-- 1 0 101 896 Aug 16 2002 welcome.msg -rw-rw-r-- 1 1000 101 849 Apr 10 2002 welcome.msg~


Ex. 4.  display listing without details in the current remote directory
EXECUTE DBMS_JAVA.SET_OUTPUT(1000000);
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  fclient_p.displayNameListStream(fid);

  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: FTP-Mirrors README README.~1~ bbc find-ls.txt find-ls.txt.asc find-ls.txt.gz find-ls.txt.gz.asc gnu html index.html iso lpf.README ls-lrR.txt ls-lrR.txt.asc ls-lrR.txt.gz ls-lrR.txt.gz.asc md5sums.txt md5sums.txt.asc md5sums.txt.gz md5sums.txt.gz.asc non-gnu old-gnu pub sha1sums.txt sha1sums.txt.asc sha1sums.txt.gz sha1sums.txt.gz.asc third-party welcome.msg welcome.msg~


Ex. 5.  listing for a single file with details
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.listStreamPath(fid, '/README');
  lv_result := REPLACE(REPLACE(lv_result, CHR(13), ''), CHR(10), '');
  DBMS_OUTPUT.PUT_LINE(lv_result);

  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: -rw-r--r-- 1 0 101 509 Apr 15 2002 up.png


Ex. 6.  listing for a single file without details
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.nameListStreamPath(fid, '/README');
  lv_result := REPLACE(REPLACE(lv_result, CHR(13), ''), CHR(10), '');
  DBMS_OUTPUT.PUT_LINE(lv_result);

  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: /html/up.png


Ex. 7.  display a listing for a single file with details
EXECUTE DBMS_JAVA.SET_OUTPUT(1000000);
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  fclient_p.displayListStreamPath(fid, '/README');

  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: -rw-r--r-- 1 0 101 509 Apr 15 2002 up.png


Ex. 8.  display a listing for a single file without details
EXECUTE DBMS_JAVA.SET_OUTPUT(1000000);
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  fclient_p.displayNameListStreamPath(fid, '/README');

  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: /html/up.png


Ex. 9.  listing for a directory with details
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.listStreamPath(fid, '/gnu');
  DBMS_OUTPUT.PUT_LINE(SUBSTR(lv_result, 1, 255));

  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: -rw-r--r-- 1 0 101 85 Apr 15 2002 default.css -rw-r--r-- 1 0 101 221 Apr 15 2002 dir.png -rw-r--r-- 1 0 101 229 Apr 15 2002 file.png -rw-rw-rw- 1 0 101 2021 Apr 15 2002


Ex. 10.  listing for a directory without details
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.nameListStreamPath(fid, '/gnu');
  DBMS_OUTPUT.PUT_LINE(SUBSTR(lv_result, 1, 255));

  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: /html/default.css /html/dir.png /html/file.png /html/index.html /html/link.png /html/motd /html/up.png


Ex. 11.  display a listing for a directory with details
EXECUTE DBMS_JAVA.SET_OUTPUT(1000000);
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  fclient_p.displayListStreamPath(fid, '/gnu');

  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: -rw-r--r-- 1 0 101 85 Apr 15 2002 default.css -rw-r--r-- 1 0 101 221 Apr 15 2002 dir.png -rw-r--r-- 1 0 101 229 Apr 15 2002 file.png -rw-rw-rw- 1 0 101 2021 Apr 15 2002 index.html -rw-r--r-- 1 0 101 343 Apr 15 2002 link.png -rw-r--r-- 1 0 101 165 Apr 15 2002 motd -rw-r--r-- 1 0 101 509 Apr 15 2002 up.png


Ex. 12.  display a listing for a directory without details
EXECUTE DBMS_JAVA.SET_OUTPUT(1000000);
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);
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  fclient_p.displayNameListStreamPath(fid, '/gnu');

  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: /html/default.css /html/dir.png /html/file.png /html/index.html /html/link.png /html/motd /html/up.png


Ex. 13.  extract the details for a listing of the current remote directory into a PL/SQL Table
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_list fclient_p.list_type;
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.listStream(fid);
  l_list := fclient_p.convertDetailListToTables(lv_result);
  FOR i IN 1..l_list.COUNT LOOP
    IF l_list(i).dir THEN
      DBMS_OUTPUT.PUT_LINE('dir : '||l_list(i).file||'  date: '||l_list(i).dy||'-'||l_list(i).mth||'-'||l_list(i).yr||' '||l_list(i).tim);
    ELSE
      DBMS_OUTPUT.PUT_LINE('file: '||l_list(i).file||'  date: '||l_list(i).dy||'-'||l_list(i).mth||'-'||l_list(i).yr||' '||l_list(i).tim);
    END IF;
  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: file: README date: 16-Aug-2002 00:00 file: README.~1~ date: 18-Aug-2000 00:00 dir : bbc date: 21-Jan-2003 16:56 file: find-ls.txt date: 10-Apr-2003 06:23 file: find-ls.txt.asc date: 10-Apr-2003 06:23 file: find-ls.txt.gz date: 10-Apr-2003 06:23 file: find-ls.txt.gz.asc date: 10-Apr-2003 06:23 dir : gnu date: 22-Mar-2003 17:59 dir : html date: 22-Mar-2003 18:13 file: index.html date: 10-Apr-2003 06:25 dir : iso date: 22-Mar-2003 18:11 file: lpf.README date: 16-Feb-1993 00:00 file: ls-lrR.txt date: 10-Apr-2003 06:23 file: ls-lrR.txt.asc date: 10-Apr-2003 06:23 file: ls-lrR.txt.gz date: 10-Apr-2003 06:23 file: ls-lrR.txt.gz.asc date: 10-Apr-2003 06:23 file: md5sums.txt date: 10-Apr-2003 06:23 file: md5sums.txt.asc date: 10-Apr-2003 06:23 file: md5sums.txt.gz date: 10-Apr-2003 06:23 file: md5sums.txt.gz.asc date: 10-Apr-2003 06:23 dir : old-gnu date: 22-Mar-2003 17:52 file: sha1sums.txt date: 10-Apr-2003 06:23 file: sha1sums.txt.asc date: 10-Apr-2003 06:23 file: sha1sums.txt.gz date: 10-Apr-2003 06:23 file: sha1sums.txt.gz.asc date: 10-Apr-2003 06:23 dir : third-party date: 22-Mar-2003 17:59 file: welcome.msg date: 16-Aug-2002 00:00 file: welcome.msg~ date: 10-Apr-2002 00:00


Ex. 14.  extract the details for a listing of file names from the current remote directory into a PL/SQL Table
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_list fclient_p.name_type;
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.nameListStream(fid);
  l_list := fclient_p.convertNameListToTables(lv_result);
  FOR i IN 1..l_list.COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('name : '||l_list(i));
  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: name : FTP-Mirrors name : README name : README.~1~ name : bbc name : find-ls.txt name : find-ls.txt.asc name : find-ls.txt.gz name : find-ls.txt.gz.asc name : gnu name : html name : index.html name : iso name : lpf.README name : ls-lrR.txt name : ls-lrR.txt.asc name : ls-lrR.txt.gz name : ls-lrR.txt.gz.asc name : md5sums.txt name : md5sums.txt.asc name : md5sums.txt.gz name : md5sums.txt.gz.asc name : non-gnu name : old-gnu name : pub name : sha1sums.txt name : sha1sums.txt.asc name : sha1sums.txt.gz name : sha1sums.txt.gz.asc name : third-party name : welcome.msg name : welcome.msg~


Ex. 15.  extract the details for a listing of a single file into a PL/SQL Table
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_list fclient_p.list_type;
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.listStreamPath(fid, '/README');
  l_list := fclient_p.convertDetailListToTables(lv_result);
  FOR i IN 1..l_list.COUNT LOOP
    IF l_list(i).dir THEN
      DBMS_OUTPUT.PUT_LINE('dir : '||l_list(i).file||'  date: '||l_list(i).dy||'-'||l_list(i).mth||'-'||l_list(i).yr||' '||l_list(i).tim);
    ELSE
      DBMS_OUTPUT.PUT_LINE('file: '||l_list(i).file||'  date: '||l_list(i).dy||'-'||l_list(i).mth||'-'||l_list(i).yr||' '||l_list(i).tim);
    END IF;
  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: file: up.png date: 15-Apr-2002 00:00


Ex. 16.  extract the details for a listing of the file name from a single file into a PL/SQL Table
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_list fclient_p.name_type;
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.nameListStreamPath(fid, '/README');
  l_list := fclient_p.convertNameListToTables(lv_result);
  FOR i IN 1..l_list.COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('name : '||l_list(i));
  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: name : /html/up.png


Ex. 17.  extract the details for a directory listing into a PL/SQL Table
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_list fclient_p.list_type;
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.listStreamPath(fid, '/gnu');
  l_list := fclient_p.convertDetailListToTables(lv_result);
  FOR i IN 1..l_list.COUNT LOOP
    IF l_list(i).dir THEN
      DBMS_OUTPUT.PUT_LINE('dir : '||l_list(i).file||'  date: '||l_list(i).dy||'-'||l_list(i).mth||'-'||l_list(i).yr||' '||l_list(i).tim);
    ELSE
      DBMS_OUTPUT.PUT_LINE('file: '||l_list(i).file||'  date: '||l_list(i).dy||'-'||l_list(i).mth||'-'||l_list(i).yr||' '||l_list(i).tim);
    END IF;
  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: file: default.css date: 15-Apr-2002 00:00 file: dir.png date: 15-Apr-2002 00:00 file: file.png date: 15-Apr-2002 00:00 file: index.html date: 15-Apr-2002 00:00 file: link.png date: 15-Apr-2002 00:00 file: motd date: 15-Apr-2002 00:00 file: up.png date: 15-Apr-2002 00:00


Ex. 18.  extract the details for a listing of file names for a directory listing into a PL/SQL Table
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_list fclient_p.name_type;
BEGIN
  fid := fclient_p.createFTPClient;
  fclient_p.login(fid, host, usernm, passwd);

  lv_result := fclient_p.nameListStreamPath(fid, '/gnu');
  l_list := fclient_p.convertNameListToTables(lv_result);
  FOR i IN 1..l_list.COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('name : '||l_list(i));
  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: name : /html/default.css name : /html/dir.png name : /html/file.png name : /html/index.html name : /html/link.png name : /html/motd name : /html/up.png

 Related Commands
 mdelete
 mdir
 mget
 mls
 modtime
 
© 1999-2003 Bear Claw Inc.