Linux
1. Introduction
2. Installation
3. SQL Query in Shell Script
4. Basic commands
5. Shell Scripts
6. Shell Script to Move File from one path to another path
1. Introduction
Similar to DB Administrator and DB Developer we have Linux Administrator and Linux Developer. Here we deal with the concepts of Linux Developer. Unix, Linux, Windows, Mac all are operating systems.
Different peripherals: Input device; Output device (Monitor); Primary memory (RAM); Auxiliary memory (Hard disc); Controllers (8051 model); CPU (8086 model). We have to develop programs that can instructs the peripheral as per the architecture of the vendor. Lets assume we have developed one application using above hardware architecture. If another end user came to develop same application but with different hardware architecture like CPU is 8085 model then we have to write altogether new program. Change in hardware – change in program, was the earlier process. Now the invention of OS removed this problem. They developed one software that controls hardware so no need to talk to hardware directly.
→ Linux is basically same as Unix. They both have same features.
→ Unix has corporate support but Linux is developed by user contributions.
→ Linux is free open source OS based in Unix features and facilities.
→ We can consider Linux as full clone of Unix.
The basic entities of Linux are Kernel, Shell and Utilities.
→ Kernel acts as a bridge between hardware and software components. Application ⇔ Kernel ⇔ Hardware devices like CPU/ Memory/ Devices
→ Shell is an interface to communicate with OS. Shell ⇔ OS ⇔ Kernel ⇔ Hardware
We have four types of Shells. Bourne Shell (SH); C Shell (CSH); Bourne Again Shell (BASH); Korn Shell (KSH);
→ Utilities are nothing but commands
2. Installation
1. Base Machine — Base machine with Windows or MAC OS.
⇓⇑
2. Virtual Machine — Install Virtual Machine software. Ideally VM player will be used but not recommended for personal use. Its preferable to use Virtual box which is provided by Oracle. VM player should be used with high configurations, mostly in industries. Virtual box is of light weight and < 0.5 GB memory will be used. Resources from Base machine will be used by Virtual machine, making base machine slow in performance.
⇓⇑
3. Configure or deploy different virtual machines as per choice.
Steps:
1. Download Virtual box software
2. Download Extension pack
3. Download Developer days [Sand box from Oracle]
4. Install Virtual box software
5. Upload Developer days software into Virtual box.
Sandbox which is provided by Oracle has Linux, Oracle 11g and Java pre-configured.
Installation:
Type virtualbox in google >> Oracle VM Virtual box (virtualbox.org) >> Dont download the latest version (currently its 5.2) as it may have some bugs >> Left side go to downloads >> Look for ‘VirtualBox older builds’ >> Look for no longer supported >> Preferably install VirtualBox 4.3 >> Download ‘Windows hosts x86/AMD64’ under ‘VirtualBox 4.3.40 (released August 22nd 2016)’>> Download ‘Extension Pack All Platforms’ under ‘VirtualBox 4.3.40 (released August 22nd 2016)’ >> Save in some drive >> Here we are just trying to get Virtual Machine
Developer days (Sandbox — We can work on Linux, Java and Oracle) >> oracle.com >> Trials and downloads >> More downloads >> Under ‘Servers and Storage Systems’, go to ‘VM VirtualBox’ >> Download
In Virtual Machine Virtual Box >> File >> Import >> Appliance >> Upload Sand Box >> Select Developer Day >> Open >> Next >> Modify name as Linux; Virtual disk image: Do not keep in c drive as it impacts performance. Do not change .vmdk extension >> Import >> Agree
In Virtual Machine Virtual Box >> Settings >> General >> Advanced tab >> Shared Clipboard: Bi-Directional >> Drag and drop: Bi-Directional >> System: Can increase memory upto green line in base memory. This can be altered based on base memory >> Shared folders >> Others >> e drive >> create new folder >> VB shared >> Select >> Ok >> Automount >> Ok>> Double click Linux >> Username root; Password: oracle >> For command line: Applications >> Accessories >> Terminals
3. SQL Query in Shell Script
#Start of V0.2 #################################################################### instance_name=$TWO_TASK file_path=`sqlplus -s $username_password<< EOF set head off set feed off set echo off set line 999 SELECT description FROM FND_LOOKUP_VALUES WHERE 1 = 1 AND lookup_type = 'custom_lookup_type' AND enabled_flag = 'Y' AND meaning = '$instance_name'; exit EOF` #Output of sql query value will be stored in file_path and to read this value use $file_path L_OUTPUT_DIR=$file_path L_SOURCE_FILE=$file_path/$file_name #End of V0.2
4. Basic commands
clear screen: clear present working directory: pwd find files with partial name: find . -name "xx_loadapps*" remove log files: rm *.log remove debug files:rm *.debug give 777 permissions: chmod 777 *.* $name == returns the value of name ${name} == Use this form when the variable name is followed by other characters, for example: filename=${file}.txt $0 == Filename of current script $n == Variables correspond to the arguments with which a script is invoked. $n is +ve decimal number corresponding to the position of an argument. The first argument is $1, second $2 and so on... $# == Number of arguments supplied to a script $* == All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2 $@ == All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2 $? == Exit status of the last command executed $$ == The process number of the current shell. For shell scripts this is the process ID under which they are executing $! == The process number of the last background command. awk -F: '{print $4}' awk == is the interpreter for the AWK Programming Language. The AWK language is useful for manipulation of data files, text retrieval and processing -F <value> == tells awk what field separator to use. In your case, -F: means that the separator is : (colon). '{print $4}' == print the fourth field (the fields being separated by 🙂 Example: Let's say that there's a file called test, and it contains the following: Hello:my:name:is:Alaa If we execute the command awk -F: '{print $4}' test, the output will be is because it is the fourth field.
5. Shell Scripts
001
clear echo "This is Message From Shell" echo "Shell Scripting is For Reusability of Commands" echo "With Shell Script We Can Keep Multiple Commands Together" echo "Process Completed...Terminating The Program"
002
clear echo "`logname` Welcome To The World of Shell Programming" echo -e "-------------------------OoO-----------------------\n" echo "The Sever Date is : `date -u '+%d-%m-%Y'`" echo "`logname` You Are Currnetly Working in \"`pwd`\" Directory" echo "The Directory Contents Are..." echo "-----------****--------------" echo ls -1 | cat -n echo echo "The Total Contents in The Directory Path \"`pwd`\" Are : `ls -1 | wc -l` Objects" echo "`logname` Leaving The Process..." echo "Returning To Shell Prompt..."
003
clear echo "`logname` Welcome To The World of Shell Programming" echo -e "-------------------------OoO-----------------------\n" echo "The Sever Date is : `date -u '+%d-%m-%Y'`" echo "`logname` You Are Currently Working in \"`pwd`\" Directory" echo -e "\nMoving Towards The Execution of Next Process...Please Wait..." echo "Establishing The Handle To Invoke The Program...This May Take Few Seconds..." chmod 100 /root/myshells/shell004.sh . /root/myshells/shell004.sh chmod 000 /root/myshells/shell004.sh
004
echo "Request Accepted From The Previous Module..." echo -e "Calling The Process Instructions For Execution...Please Wait...\n" echo "The Directory Contents Are..." echo "-----------****--------------" echo ls -1 | cat -n echo echo "The Total Contents in The Directory Path \"`pwd`\" Are : `ls -1 | wc -l` Objects" chmod 100 /root/myshells/shell005.sh . /root/myshells/shell005.sh chmod 000 /root/myshells/shell005.sh
005
echo "Final Module For Exiting is Initiated...." echo -e "Calling The Process Implementations For Releasing The Resources...Please Wait...\n" echo "`logname` Leaving The Process..." echo "Returning To Shell Prompt..." echo "The Total Batch Was Executed Successfully...Leaving The Application"
006
clear echo "`logname` Welcome To The World of Shell Programming" echo -e "-------------------------OoO-----------------------\n" echo "The Sever Date is : `date -u '+%d-%m-%Y'`" echo "`logname` You Are Currnetly Working in \"`pwd`\" Directory" echo "The Directory Contents Are..." echo "-----------****--------------" echo ls -1 | cat -n & echo echo "The Total Contents in The Directory Path \"`pwd`\" Are : `ls -1 | wc -l &` Objects" echo "`logname` Leaving The Process..." echo "Returning To Shell Prompt..."
007
firstname="Srikanth" middlename="D" lastname="G" echo -e "\nThe Given First Name is : $firstname" echo -e "\nThe Given Middle Name is : $middlename" echo -e "\nThe Given Last Name is : $lastname" echo -e "\nThe Full Name is : $firstname $middlename $lastname"
008
v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Sum of $v_num1 And $v_num2 is : $((v_num1 + v_num2))"
009
v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Diffrence of $v_num1 And $v_num2 is : $((v_num1 - v_num2))"
010
v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Product of $v_num1 And $v_num2 is : $((v_num1 * v_num2))"
011
clear v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Quotient of $v_num1 And $v_num2 is : $((v_num1 / v_num2))"
012
clear v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Remainder of $v_num1 And $v_num2 is : $((v_num1 % v_num2))"
013
clear v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Power of $v_num1 And $v_num2 is : $((v_num1 ** v_num2))"
014
clear v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Sum of $v_num1 And $v_num2 is : `expr $v_num1 + $v_num2`"
015
clear v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Difference of $v_num1 And $v_num2 is : `expr $v_num1 - $v_num2`"
016
clear v_num1=25 v_num2=10 echo -e "\nThe First Number is : $v_num1" echo -e "\nThe Second Number is : $v_num2" echo -e "\nThe Procuct of $v_num1 And $v_num2 is : `expr $v_num1 \* $v_num2`"
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
functionone() { echo "Executing From Function One" echo "Message From Function One" echo "Closing The Operations in Function One" } functiontwo() { echo "Executing From Function Two" echo "Message From Function Two" echo "Closing The Operations in Function Two" } functionthree() { echo "Executing From Function Three" echo "Message From Function Three" echo "Closing The Operations in Function Three" } echo "Main Part of The Shell" echo "---------***----------" echo "Calling Fucntion One" functionone echo "Returned From Function One" echo "Calling Fucntion Two" functiontwo echo "Returned From Function Two" echo "Calling Fucntion Three" functionthree echo "Returned From Function Three" echo "--------OOO---------" echo "End of The Main Part" echo "--------000---------"
066
functionone() { echo "Executing From Function One" echo "Message From Function One" echo "Calling Function Two" functiontwo echo "Returned From Function Two" echo "Closing The Operations in Function One" } functiontwo() { echo "Executing From Function Two" echo "Message From Function Two" echo "Calling Function Three" functionthree echo "Returned From Function Three" echo "Closing The Operations in Function Two" } functionthree() { echo "Executing From Function Three" echo "Message From Function Three" echo "Closing The Operations in Function Three" } echo "Main Part of The Shell" echo "---------***----------" echo "Calling Function One" functionone echo "Returned From Function One" echo "--------OOO---------" echo "End of The Main Part" echo "--------000---------"
067
myclear() { clear } echo "Mein Part of The Code Will Beging Here" echo "-----------------000------------------" choice= read -p "Do You Want To Clear The Screen : " choice if [ $choice == "Yes" ] then myclear else echo "You Are Not Interested To Clear The Screen" fi
068
clear add() { echo "The Sum of $num1 And $num2 is : $(( num1 + num2 ))" } echo "Main Part of The Shell" echo "---------000----------" num1= num2= read -p "Enter The First Number : " num1 read -p "Enter The Second Number : " num2 add echo "Completed The Task"
069
clear add() { echo "The Sum of $1 And $2 is : $(( $1 + $2 ))" } echo "Main Part of The Shell" echo "---------000----------" num1= num2= read -p "Enter The First Number : " num1 read -p "Enter The Second Number : " num2 add num1 num2 echo "Completed The Task"
6. Shell Script to Move File from one path to another path
#******************************************************************************************************# # - COPYRIGHT NOTICE - # #****************************************************************************************************** # # Project : ABC Interfaces # # Title : XXAP ABC Move File # # File Name : xxap_abc_move_file.prog # # Created by : ABC # # Creation Date : 21-APR-2022 # # Description : This script moves the output file generated from OUT directory to # # OUTBOUND directory # # # # Change History : # # # #=============================================================================# # Date Name Revision Remarks # #=============================================================================# # 21-APR-2022 Srikanth G 0.1 Initial Version # #*******************************************************************************************************# #!/bin/bash # Standard Parameters # --------------------------- # $0 --> Concurrent Program Name # $1 --> APPS username/password # $2 --> FND User ID # $3 --> FND User Name # $4 --> Concurrent Request ID # User-defined Parameter # ------------------------------ # $5 --> Output File Request Id # $6 --> File Name ####################################################################### #****************************************************************# #** Assigning parameters to variables with meaningful name **# #***************************************************************# l_request_id=$5 l_file_name=$6 #*********************# #** Directory Path **# #*********************# #APPLCSF == /u01/oraout/instance_name #APPLOUT == out #APPLLOG == log SOURCE_DIR=$APPLCSF/$APPLOUT SOURCE_FILE_NAME='o'$l_request_id'.out' DESTINATION_DIR=$APPLCSF/outbound/stack/ABC DESTINATION_FILE_NAME=$l_file_name echo ` pwd ` #Display Parameters echo Request ID is $l_request_id echo Source Directory is $SOURCE_DIR echo Source File Name $SOURCE_FILE_NAME echo Destination Directory is $DESTINATION_DIR echo Destination File Name $DESTINATION_FILE_NAME cd $SOURCE_DIR echo ` pwd ` if [ -f $SOURCE_DIR/$SOURCE_FILE_NAME ] then cp $SOURCE_DIR/$SOURCE_FILE_NAME $DESTINATION_DIR/$DESTINATION_FILE_NAME echo Source file $SOURCE_DIR/$SOURCE_FILE_NAME has been moved to $DESTINATION_DIR/$DESTINATION_FILE_NAME else echo " Source File Archiving Failed, File NOT FOUND, Check DIR or File name " fi echo "******** Host Program Execution completed *************" #end of script
Save the file as xxap_abc_move_file.prog and place in bin folder (/u01/app/instance_name/apps/apps_st/appl/short_name/12.0.0/bin)
Create soft link via Winscp > Terminal
ln -s /u01/app/instance_name/apps/apps_st/appl/short_name/12.0.0/bin/fndcpesr xxap_abc_move_file
Not sure below:
ln -s $FND_TOP/bin/fndcpesr xxsb_tsys_check_file
ln -s $XXSB_TOP/bin/fndcpesr xxsb_tsys_check_file
ln -s xxsb_tsys_check_file xxsb_tsys_check_file
In the concurrent program executable enter the execution file name as xxap_abc_move_file (without .prog). Define concurrent program with two user defined parameters as P_REQUEST_ID and P_FILE_NAME. Call this program in main procedure as below, where l_conc_req_id and v_filename are variables in main procedure
lv_request_id :=fnd_request.submit_request(
application =>’short_name’,
program =>’MOVE_FILE’,
description =>NULL /*Optional; Concurrent program description*/,
start_time =>SYSDATE /*Optional; Start time of Concurrent program*/,
sub_request =>false,
argument1 =>l_conc_req_id,
argument2 =>v_filename
);