Pages

OracleEBSpro is purely for knowledge sharing and learning purpose, with the main focus on Oracle E-Business Suite Product and other related Oracle Technologies.

I'm NOT responsible for any damages in whatever form caused by the usage of the content of this blog.

I share my Oracle knowledge through this blog. All my posts in this blog are based on my experience, reading oracle websites, books, forums and other blogs. I invite people to read and suggest ways to improve this blog.


Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

Tuesday, May 14, 2013

Oracle Apps Concurrent program Output as Email


Using the below Unix SH file we can send the Concurrent program Output as Email.Please pass the request id of the Concurrent program and email address.

-------------------------------------------------------------------------------------

#!/bin/ksh
#################################
# Parameters
# 1 = echo "Start of the Program"
#################################
# File Name #
##############
REQUEST_ID=`echo $*awk '{print $9}' sed 's/"//g'`
REQUEST_ID=`eval "echo $REQUEST_ID"`
echo "Request Id= " ${REQUEST_ID}
###################
# Enail #
###################
mail_add=`echo $* awk '{print $10}' tr -d "`
echo "mail id : ${mail_add}"
req_file='${req_id}.out'
###################
# Data Directory #
###################
cd $APPLCSF/$APPLOUT
uuencode ${REQUEST_ID} ${REQUEST_ID} mailx -v -s"XXX Banks Accounts&PO expense Creation Out File" "$mail_add"

Thursday, April 25, 2013

Shell scripting Standard parameter

Objectives:


  • Steps to Register Shell Script as a concurrent program
  • Sample Shell Script to copy the file from source to destination
Steps to Register Shell Script as a concurrent program

step 1:
=======
Place the <name>.prog script under the bin directory for your
applications top directory.

For example, call the script ERPS_DEMO.prog and place it under
$CUSTOM_TOP/bin


step 2:
=======
Make a symbolic link from your script to $FND_TOP/bin/fndcpesr
For example, if the script is called ERPS_DEMO.prog use this:


ln -s $FND_TOP/bin/fndcpesr ERPS_DEMO

This link should be named the same as your script without the
.prog extension.


Put the link for your script in the same directory where the
script is located.


step 3:
=======
Register the concurrent program, using an execution method of
‘Host’. Use the name of your script without the .prog extension
as the name of the executable.


For the example above:
Use ERPS_DEMO


step 4:
=======
Your script will be passed at least 4 parameters, from $1 to $4.

$1 = orauser/pwd
$2 = userid(apps)
$3 = username,
$4 = request_id


Any other parameters you define will be passed in as $5 and higher.
Make sure your script returns an exit status also.


Sample Shell Script to copy the file from source to destination

#Note: If you see # in front of any line it means that it’s a comment line not the actual code
#** ********************************************************************
# Created By : Prudhvi A
# Creation Date : 19-FEB-2008
# Script Name : ERPSCHOOLS.prog
# Description : This Script accepts three parameters
# 1)Data File Name 2)Source Directory Path 3)Target Directory Path
# Then copy the file from source location to target location.
# If copy fails send the error status/message to concurrent program so that user can see status.
#
#
# ========
# History
# ========
# Version 1 Prudhvi A 19-FEB-2008 Created for erpschools.com users
#
#** ********************************************************************
#Parameters from 1 to 4 i.e $1 $2 $3 $4 are standard parameters
# $1 : username/password of the 
database
# $2 : userid
# $3 : USERNAME
# $4 : Concurrent Request ID
DataFileName=$5
SourceDirectory=$6
TargetDirectory=$7
echo “————————————————–”
echo “Parameters received from concurrent program ..”
echo ” Time : “`date`
echo “————————————————–”
echo “Arguments : ”
echo ” 
Data File Name : “${DataFileName}
echo ” SourceDirectory : “${SourceDirectory}
echo ” TargetDirectory : “${TargetDirectory}
echo “————————————————–”
echo ” Copying the file from source directory to target directory…”
cp ${SourceDirectory}/${DataFileName} ${TargetDirectory}
if [ $? -ne 0 ]
# the $? will contain the result of previously executed statement.
#It will be 0 if success and 1 if fail in many cases
# -ne represents not “equal to” 

then
echo “Entered Exception”
exit 1
# exit 1 represents concurrent program status. 1 for error, 2 for warning 0 for success
else
echo “File Successfully copied from source to destination”
exit 0
fi
echo “****************************************************************”


Friday, April 19, 2013

How to run my script as a background job in UNIX? - nohup

Have a script with in it for example

#!/bin/ksh
sqlplus user/pass@instance < analyze table xxx compute statistics;
analyze table yyy estimate statistics;
exit
EOF

The from the command line

nohup ./script.ksh &

You can then disonnect your session and it will run in the background

------------------------------------------------------------------------------------

Unix Nohup: Run a Command or Shell-Script Even after You Logout

When you execute a Unix job in the background ( using &, bg command), and logout from the session, your process will get killed. You can avoid this using several methods — executing the job with nohup, or making it as batch job using at, batch or cron command.

This quick tip is for beginners. If you’ve been using nohup for a while, leave us a comment and tell us under what situations you use nohup.
In this quick tip, let us review how to make your process running even after you logout, using nohup.
Nohup stands for no hang up, which can be executed as shown below.
nohup syntax:
# nohup command-with-options &
Nohup is very helpful when you have to execute a shell-script or command that take a long time to finish. In that case, you don’t want to be connected to the shell and waiting for the command to complete. Instead, execute it with nohup, exit the shell and continue with your other work.

Explanation about nohup.out file

By default, the standard output will be redirected to nohup.out file in the current directory. And the standard error will be redirected to stdout, thus it will also go to nohup.out. So, your nohup.out will contain both standard output and error messages from the script that you’ve executed using nohup command.
Instead of using nohup.out, you can also redirect the output to a file using the normal shell redirections.

Example: Printing lines to both standard output & standard error

while(true)
do
echo "standard output"
echo "standard error" 1>&2
sleep 1;
done

Execute the script without redirection

$ nohup sh custom-script.sh &
[1] 12034
$ nohup: ignoring input and appending output to `nohup.out'

$ tail -f nohup.out
standard output
standard error
standard output
standard error
..

Execute the script with redirection

$ nohup sh custom-script.sh > custom-out.log &
[1] 11069
$ nohup: ignoring input and redirecting stderr to stdout

$ tail -f custom-out.log
standard output
standard error
standard output
standard error
..
If you log-out of the shell and login again, you’ll still see the custom-script.sh running in the background.
$ ps aux | grep sathiya
sathiya  12034  0.0  0.1   4912  1080 pts/2    S    14:10   0:00 sh custom-script.sh

Tuesday, April 9, 2013

How to find file version on a Server

strings -a $INV_TOP/forms/US/INVMWBIV.fmx | grep '$Header'

$Header: INVMWBIV.fmb 120.101.12000000.30 2008/07/17 07:07 ckrishna noship 

OR

grep '$Header' $INV_TOP/patch/115/sql/INVTXGGB.pls

/* $Header: INVTXGGB.pls 120.55.12000000.15 2007/10/25 11:02:58 ksaripal ship $ */

Wednesday, February 27, 2013

Unix Commands


I am not a expert in unix and i always maintain a list of simple commands to work in the black screens..here i am posting it for people like for easy reference...

How to convert a file from dos mode to unix??
some time shell script developed in the window environment will create some problems because of carriage returns and other thing..those can be removed using the follwoing command

dos2unix 
dos2unix movepdf

How to search files in unix??

find . -name "rc.conf" -print

This command will search in the current directory and all sub directories for a file named rc.conf.

Note: The -print option will print out the path of any file that is found with that name. In general -print wil print out the path of any file that meets the find criteria

How to search for a string in a selection of files (-exec grep ...).??

find . -exec grep "murthy ganjam" '{}' \; -print

If you want to just find each file then pass it on for processing use the -q grep option.
This finds the first occurrance of the search string. It then signals success to find and find continues searching for more files.

find . -exec grep -q "murthy ganjam" '{}' \; -print
This command is very important for process a series of files that contain a specific string.
You can then process each file appropriately.

How to view Files in UNIX??
use the cat command

cat filename
The more command will pause after displaying a page of text, and you can go on to the next page of text by hitting the space bar.
You can also do a keyword search of the text by typing

/keyword
For example, if you were looking through a file using the more command, and wanted to skip to the word "drosophila" you would type

/drosophila
and the more command would search through the file until it found that word.

LISTING FILES:

ls -a list all files, including the hidden ones
ls -g list which group owns the files
ls -lag list everything
ls *.txt list only files with a .txt on the end
ls data* list only files that start with the word "data"
ls -lrt list of all the files sorted

ls -la |grep '^d' Look only for files that are directories
ls -la |grep -v '^d' Let's only look for files that are not directories

COPY COMMAND:

cp -r * /tmp you would copy everything in the directory and RECURSIVELY (-r)
everything in the subdirectories underneath that directory to the /tmp directory.

cp file1 file2 copy file1 to a file called file2

cp file1 /tmp copy file1 to the /tmp directory

cp file1 ~smith copy file1 to the home directory of "smith"

cp * /tmp copy everything in the directory to the /tmp directory

MOVE COMMAND:

mv file1 file2 rename file1 to the name file2

mv file1 /tmp move file1 to the /tmp directory

mv file1 ~smith move file1 to the home directory of "smith"

mv * /tmp move everything in the directory to the /tmp directory

mv dir2 /tmp move the directory called dir2,and everything in it, to the /tmp directory
There is no rename command in unix use this command to rename... 

Remove Command:

rm * delete everything in a subdirectory

rm *.txt remove only files with a .txt on the end

rm data* remove only files that start with the word "data"

rm -r dir2 removes everything in the subdirectory "dir2"

CD Command:

cd change to your home directory

cd .. move up one level

cd ~applmgr change to the home directory of user "smith"

cd /tmp change to the /tmp subdirectory

Monday, February 18, 2013

Basic Unix Vi editor command


Unix Vi editor command keys:
ZZ
Q
<ESC>
:<cmd>
:!<cmd>
^g
^f
^b
^d
^u
<x>G
/<x>
?<x>
n
N
]]
[[
%
^l
^r
z<CR>
z-
^e
^y
H
L
M
+
hjkl
0
$
f<x>
F<x>
Exit, saving changes
Enter ex mode
End of insert
Execute ex command
Shell command
Show filename/size
Forward one screen
Back one screen
Forward half screen
Backward half screen
Go to line <x>
Search forward for <x>
Search backward for <x>
Repeat last search
Reverse last search
Next section/function
Previous section/function
Find matching () { or }
Redraw screen
Refresh screen
Current line at top
Current line at bottom
Scroll down one line
Scroll up one line
revious context
Home window line
Last window line
Middle window line
Next line
Cursor movement:
left/down/up/right
Beginning of line
End of line
Find <x> forward
Find <x> backward
t<x>
T<x>
<x>|
w,W
b,B
e,E
^h
^w
^?
~
a
i,I
A
o
O
r
R
d
dd
c
y
C
D
s
S
J
x
X
Y
p
P
<<
>>
u
U
Up to <x> forward
Back up to <x>
Go to column <x>
Forward one word
Back one word
End of word
Erase last character
Erase last word
Interrupt
Toggle character case
Append after
Insert before
Append at end of line
Open line below
Open line above
Replace character
Replace characters
Delete
Delete line
Change
Yank lines to buffer
Change rest of line
Delete rest of line
Substitute character
Substitute lines
Join lines
Delete after
Delete before
Yank current line
Put back lines
Put before
Shift line left
Shift line right
Undo last change
Restore current line
File Options:
sh      Invoke shell
vi      Vi mode
wq      Write and quit
w <f>   Write file <f>
w! <f>  Overwrite file <f>

EX MODE COMMANDS:

q
q!
r <f>
set <x>
set no<v>
set all
Quit
Quit, discard changes
Read in file <f>
Enable option
Disable option
Show all options