Help with shell script on Month Changing Logic


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with shell script on Month Changing Logic
# 1  
Old 01-21-2013
HP Help with shell script on Month Changing Logic

Hi Unix Experts,

Happy Morning to all !! Smilie

I am new to UNIX Shell Scripting and at my begineer level. To get acquainted to scripting, I am trying to create a script.

The details/requirements of my script was to create a script with month changing logic in it so that on every 6th Working day, it calls one more script that will process certain data.

I have just started to put my heads on it. Created a table excluding the public holidays so that 6th Working day is obtained correctly. Now I am struck in bringing the month changing logic in it. Here is my try.

Code:
e1=`sqlplus -s ${UNAME}/${UPSWD}@${ODS_CON} << EOF
set heading off;
set headsep off;
set underline off trims on;
select MONTH_TIME_KEY from time_dim  where date_start=trunc(sysdate);
EOF`

e2=0`echo $e1  | cut -c5-6`

cd /backups/micky/sample
cat /dev/null > SAMPLE_WORKLIST.lst
echo $e2 > SAMPLE_WORKLIST.lst

nohup extract_sample.sh &
exit

Can you please guide me on this. Many thanks.

Regards,
Micky

Last edited by Scrutinizer; 01-22-2013 at 12:38 AM.. Reason: code tags
# 2  
Old 01-22-2013
Your requirement is not so clear, but if you are looking for a way of advancing the month I suggest you to do it in DB.

You can use SQL function: ADD_MONTHS
Code:
select to_char(ADD_MONTHS(sysdate,1),'mon') from dual;
feb

# 3  
Old 01-23-2013
Hi Bipinajith,

Thanks for your valuable suggestion.

I have a table (time_dim) which I have created in db where I can find what's the current working day. The script I am looking for is the one which will hit this table and pull out what's the current working day (say as 1 for Monday, 2 being Tuesday and so on..).

Your suggestion and help towards this is highly appreciated.
# 4  
Old 01-23-2013
Use SQL to_char function to format the date as per your requirement.

E.g. If you need the full day name:
Code:
select to_char(sysdate,'day') from dual;
wednesday

Check Oracle docs for further reference. I hope this helps.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to copy the previous month files using shell script?

could you please assist the below query. i had written the below piece of code to copy the files from one directory to another. For current month files had been copied ,unfortunately the previous month files not copied. Please find the below directory structure:- ls -lrt total 1824... (2 Replies)
Discussion started by: venkat918
2 Replies

2. Shell Programming and Scripting

Shell script logic

Hi I have a requirement where I have to generate a mail/alert to the user if any QA check is failed. our oracle jobs run in unix environment and log file is created . Sample is given below . SELECT * FROM product.fact_tally WHERE period_id = '20130401' ; LIMIT 5; Ideally the above... (4 Replies)
Discussion started by: systemee
4 Replies

3. Shell Programming and Scripting

Run shell script alternate week per month

Hi All, Requirement :- I have shell script in kern shell ,have to run alternate week per month example-today's date is 27 Mar 2013 and my script will run today then for the next time when it will run it should check 1st what was the last run date(27 Mar 2013) if it is matched 15days from... (2 Replies)
Discussion started by: krupasindhu18
2 Replies

4. Answers to Frequently Asked Questions

Finding the nth Particular Week in a Month – shell script

I see lot of request posted in internet to find out the day of nth week in a Month. example: what is the date of 3rd Sunday in October What is the date of 2nd Friday in June 2012 what is the date of 4th Saturday in January 2011..etc.. The below shell script is used to find out the... (1 Reply)
Discussion started by: itkamaraj
1 Replies

5. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

6. Shell Programming and Scripting

Validating month value in shell script

Hi, the below script is to get & check the correct values for minutes (0-59) that is inputed by user : printf "$FBOLD\nPlease enter the minutes (0-59): $FREG" read MIN case "$MIN" in |) break 2;; *) echo "" echo "Invalid minutes, please... (4 Replies)
Discussion started by: milink
4 Replies

7. Shell Programming and Scripting

Restart Logic for a Korn Shell Master Script

Hello All, I was wondering if someone can help me to develop restart logic for a Korn Shell program (a master script) that I am developing. The program is design to invoke a series of child processes (Korn Shell Scripts) whose function is to create a series of load files on a specified mount... (0 Replies)
Discussion started by: jonesdk5
0 Replies

8. Shell Programming and Scripting

Logic in Shell script required

Hi, I have the following in my shell script sqlplus << EOF username/password @$SCRIPTS_DIR/refresh.sql > /home/oracle/sql/refreshsql.log EOF RETCODE=$? if ; then echo "ERROR: sqlplus command finished with error code {RETCODE}" /usr/bin/mailx -s "REFRESHING FMLA CONTACT... (2 Replies)
Discussion started by: welldone
2 Replies

9. UNIX for Dummies Questions & Answers

Getting month and changing format

Hello, I would like to get todays moth and write it in this format: _06_ Any ideas? (7 Replies)
Discussion started by: marringi
7 Replies

10. Shell Programming and Scripting

Query on a shell script logic

Hello people, I am new to shell scripting and hoping to get a quick answer to my query. I am writing a simple script which needs to call an executale which generates an output file. Once the output file is generated I have to do a couple of more task with that file. The executable ideally... (1 Reply)
Discussion started by: tipsy
1 Replies
Login or Register to Ask a Question