Sponsored Content
Top Forums Shell Programming and Scripting Creating a file inside a script Post 302068818 by sendhilmani on Tuesday 21st of March 2006 06:37:44 AM
Old 03-21-2006
This is the script:


DEFINE_ENV_VAR()
{
. /usr/dacscan/bin/DSCANenv
LOG=/dacscan/words/shdsl_mrp_verify_eqpt
DEFINE_ENV_VAR()
{
. /usr/dacscan/bin/DSCANenv
LOG=/dacscan/words/shdsl_mrp_verify_eqpt
ORACLE_HOME=/opt/oracle
ORACLE_SID=S
export ORACLE_HOME
export ORACLE_SID
TDATE=`date "+%m%d%y"$$`
DEFINE_ENV_VAR()
{
. /usr/dacscan/bin/DSCANenv
LOG=/dacscan/words/shdsl_mrp_verify_eqpt
ORACLE_HOME=/opt/oracle
ORACLE_SID=S
export ORACLE_HOME
export ORACLE_SID
TDATE=`date "+%m%d%y"$$`
LOGFILE=$log.$TDATE
}
user=`echo $LOGNAME`
if [ $user != dacscan ]
then
echo "Please login as 'dacscan' to run this tool" > $LOGFILE
exit 1
else
echo "U r a valid user and now the check for single instance is going on" | tee -a $LOGFILE
echo "U r user validation is successful"
fi

if [ ! -f /tmp/shdsl_mrp_verify_eqpt.tmp ]
then
ps -ef | grep shdsl_mrp_verify_eqpt.sh | awk '{print $8}' > /tmp/shdsl_mrp_verify_eqpt.tmp
else
echo "Another instance of the tool is already running. Only one instance of the tool can be run at a given point of time" | tee -a $LOGFILE
echo "Cannot run the tool as already another instance of the tool is running"
exit
fi

Create_Proc()
{
create=`sqlplus -s dacscan/mnc <<!
set serveroutput on;
start shdsl_mrp_verify_eqpt.sql;
!`
if [[ $(echo $create | grep "ORA-") != "" ]]
then
echo "Error occured while creating the procedure. Check the Activity log file for further details" | tee -a $LOGFILE
rm /tmp/shdsl_mrp_verify_eqpt.tmp
exit 1
fi
}

Run_Proc()
{
status=`sqlplus -s dacscan/mnc <<!
set serveroutput on;
spool shdsl_mrp_verify_eqpt;
exec EQPT_VERIFY;
spool off;
!`
if (($?!=0))
then
echo "Unable to connect to oracle for running/executing the procedure" |tee -a $LOGFILE
rm /tmp/shdsl_mrp_verify_eqpt.tmp
exit 1
elif [[ $(echo $status | grep "ORA-") != "" ]]
then
echo "Error occured while executing the procedure" | tee -a $LOGFILE
rm /tmp/shdsl_mrp_verify_eqpt.tmp
exit 1
fi
}
rm /tmp/shdsl_mrp_verify_eqpt.tmp
DEFINE_ENV_VAR
Create_Proc
Run_Proc

Now tell me what do I have to do.

Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to find Script file location inside script

I have to find out the file system location of the script file inside script. for example a script "abc.sh" placed anywhere in the file system when executed shold tell by itself the location of it. example #pwd / #./abc this is / #cd /root #./abc this is /root #cd / #/root/abc this... (10 Replies)
Discussion started by: asami
10 Replies

2. Shell Programming and Scripting

script to check for a condition inside a file

Hi I am writing a script file which sends the log files along with their size in a folder named log to a file called temp.log using the following cmd: ls -st 190_GSTV_HUX_003QISCGSK026** >> /home/user/temp.log the temp.log looks like this: 16 190_GSTV_HUX_003QISCGSK026_message070321.log ... (11 Replies)
Discussion started by: kiran1112
11 Replies

3. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

4. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

5. Shell Programming and Scripting

Need help in creating file restoration script from a backup script.

Hi all i am struggling in creating a restore of env files while doing applications clone. the first file i created for copying the important configurations file which is running perfect now for reverting the changes i mean when i am restoring these files to its original places i have to do... (7 Replies)
Discussion started by: javeedkaleem
7 Replies

6. UNIX for Dummies Questions & Answers

File operations are failing inside the script

Hi, does any one know the environmental parameter that I have to set so as to make sure the file operations run properly within the script. right now when I am doing a cat from within the script nothing happens, same is the case when I do a grep. when I am doing awk '{print $0 }' its printing... (1 Reply)
Discussion started by: ahmedwaseem2000
1 Replies

7. Shell Programming and Scripting

Creating loops inside a file and extracting and loading data

Help needed (1 Reply)
Discussion started by: Chand Shrestha
1 Replies

8. Shell Programming and Scripting

Running .sh file inside a shell script

Hello, You might help a newbie like me, I am trying to run a .sh inside my shell script. After running that I need to execute below commands. Here's how my scripts looks like. Hope you can help: #!/bin/sh cd $ORACLE_HOME/owb/bin/unix ./OMBPlus.sh ---> goes to OMB+> directory cd... (10 Replies)
Discussion started by: aderamos12
10 Replies

9. Shell Programming and Scripting

Script to validate dates inside a file

Hi All, Looking forward a script with below requirement.Please let me know if any pointers. - there is a file which contains date - script will go inside the file and validate date is T-1 and for Friday T-3 - Send email with status -Shell is Ksh (2 Replies)
Discussion started by: dattatraya
2 Replies

10. Shell Programming and Scripting

Creating new file inside a for loop

Hi, I have list of files present in a folder. I want to search for a particular keyword sequentially and create a file which will be later used by some other program. Input files: $ ls a.dsx b.dsx c.dsx Dataline_.txt Dataline.txt loop.sh $ cat *.dsx help tyiis global for i in... (4 Replies)
Discussion started by: mac4rfree
4 Replies
script(1)						      General Commands Manual							 script(1)

NAME
script - Makes a transcript of terminal session SYNOPSIS
script [-a] [file] The script command makes a transcript of everything printed on your terminal. OPTIONS
Appends the transcript to file rather than writing it to file. OPERANDS
The name of an output file that will contain the transcript of the session. If this parameter is omitted, the file typescript is written. DESCRIPTION
The transcript is written to file, or appended to file if the -a option is given. If no file name is given, the transcript is saved in the file typescript. The script ends when the forked shell exits. This program is useful when you are using a CRT and want a hard-copy record of the dialog (for example, a technical writer might create an example of a working session this way). If you specify the -a option and the file does not exist, it is created. If you do not specify the -a option and the file exists, it is replaced. RESTRICTIONS
The script command requires a streams based terminal. In single user mode, streams may not be enabled. Under these circumstances, script will exit with no action. If you are the superuser and need to run this command in single user mode, use the following special instruc- tions. Enabling Streams If it is necessary to enable a streams environment in the single user mode, enter the command /sbin/init.d/streams. This command is avail- able to the superuser only. SEE ALSO
Commands: autopush(8), cat(1), echo(1), strsetup(8), tee(1) System Administration script(1)
All times are GMT -4. The time now is 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy