1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Code to check File is existing in FTP

Discussion in 'SQL PL/SQL' started by Vikram S, May 9, 2014.

  1. Vikram S

    Vikram S Active Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    80
    Hi,


    Requirement is to check whether the file is existing in the ftp server.

    Please guide me regarding this.


    Thanks & Regards,
    Vikram S
     
  2. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    If ftp server is linux,

    locate file_name

    also check every directory by ls command.
     
  3. Vikram S

    Vikram S Active Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    80
    Hi Jagadekara Reddy,

    Yeah ftp server is Linus.


    Thanks & Regards,
    Vikram S
     
  4. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Then type locate file_name
     
  5. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Hi.
    You want to check file existence through UTL_FILE or according to the FTP protocol?


    for example :
    Additional links :

    http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/u_file.htm#ARPLS70903
    http://www.oracle-base.com/articles/8i/file-handling-from-plsql.php

    http://www.oracle-base.com/articles/misc/ftp-from-plsql.php
     
  6. Vikram S

    Vikram S Active Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    80
    Hi,

    I need to check in FTP server.



    Thanks & Regards,
    Vikram S
     
  7. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
  8. Vikram S

    Vikram S Active Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    80
    Hi,

    I am using a ftp package to access files in ftp server.

    DECLARE
    l_conn UTL_TCP.connection;
    BEGIN
    l_conn := ftp.login( hosturl , port , username , password );
    ftp.binary(p_conn => l_conn);
    FTP.GET(P_CONN => L_CONN,
    p_from_file => '/u01/my_dir/',
    P_TO_DIR => 'MY_DOCS',
    p_to_file => '1000.csv');
    ftp.logout(l_conn);
    END;

    Error report:
    ORA-24247: network access denied by access control list (ACL)
    ORA-06512: at "SYS.UTL_TCP", line 17
    ORA-06512: at "SYS.UTL_TCP", line 267
    ORA-06512: at "INTERNALAPPS.FTP", line 77
    ORA-06512: at line 4

    I have taken all grant permission for all packages and still facing this issue.

    Please help with this issue.

    Thanks & Regards,
    Vikram S
     
  9. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    It works?

    Code (SQL):


    SELECT sys.utl_inaddr.get_host_name('your server ip') FROM dual;

     

    Check priviledge...

    Code (SQL):


    DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
        acl => 'network_services.xml',
        description => 'FTP ACL',
        principal => 'LOADSCHEMA',
        is_grant => TRUE,
        privilege => 'connect');
     
      DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
        acl => 'network_services.xml',
        principal => 'LOADSCHEMA',
        is_grant => TRUE,
        privilege => 'resolve');
     
      DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
        acl => 'network_services.xml',
        host => '*');
     
      COMMIT;            


     


    That output these sql-query ?
    Code (SQL):

    SELECT HOST,LOWER_PORT,UPPER_PORT,ACL FROM  DBA_NETWORK_ACLS;

    SELECT ACL,PRINCIPAL,PRIVILEGE,IS_GRANT,INVERT,START_DATE,END_DATE FROM DBA_NETWORK_ACL_PRIVILEGES;