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!

Shell script to check ftp connection is established and folder permissions are in place

Discussion in 'Oracle Apps Technical' started by kartheekbk, Apr 27, 2016.

  1. kartheekbk

    kartheekbk Active Member

    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    80
    Hi Forum,

    Hope all are good!

    in Oracle R12:
    I'm using the below shell script saved in a file XXEXTRACTTMT, which imports the files from remote server SFTPTDA120FTP into our Oracle application.server.

    i am running this file thru concurrent program in Oracle and I see the files are getting loaded in to Oracle.


    !ftp -i -n SFTPTDA120FTP
    user amaran K!ka@123
    ascii

    cd Forms
    cd Reprots
    lcd /d90/oracle/PROD/apps/apps_st/appl/EXTRACT/files
    mget timesheet*
    bye


    now the requirement is :
    I want to test the below
    > check whether the remote connection is established ?
    ex: when we running the conc program, if the program is failed to connect the remote server( say password is changed)
    then I should get some log messages in my conc request log.

    > check whether the user has required permissions to retrieve the files in folder: Forms/Reports/


    can you help to modify the code and add the conditions based on the requirement provided ?
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Why are you running this from the SQL> prompt? You should be writing this as a stand-alone shell script so you can use $? (the built-in exit status variable) to check for a non-zero status.
     
  3. kartheekbk

    kartheekbk Active Member

    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    80
    Hi Zargon,

    Thanks for the reply. Can you please share the sample snippet code of using $? command ?
    you can use the above code as example.
     
  4. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    ftp -i -n SFTPTDA120FTP <<EOF
    user amaran K!ka@123
    ascii

    cd Forms
    cd Reprots
    lcd /d90/oracle/PROD/apps/apps_st/appl/EXTRACT/files
    mget timesheet*
    bye
    EOF

    status=$?

    if [ $status -eq <some error code here> ]
    then
    echo "<some error message here"
    elif [ $status -eq <some other error code> ]
    then
    echo ...
    ...

    fi

    exit $status

    You will need to look up the various exit codes for the errors that ftp can generate; those should be in the online UNIX/Linux manual pages.
     
  5. kartheekbk

    kartheekbk Active Member

    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    80
    Very thanks Zargon for the sample code. much appreciated!!
    I'm novice to unix shell scripts, I will try this and let you know the outcome.