• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Ksh script

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to write a script where i have to invoke a stored procedure and need to track time it took in excecution.
If this time is less then 2 minutes - i have to sleep for remaining time.

I have the logic but i am new to unix.
I don't even know - which shell i should use.

i used the command echo $SHELL and found out that it's KShell.

I don't know how to change the shell as well.

logic i understand should be:

save current time in a variable
excecute the stored procedure
find out difference between current time and the time saved earlier
If it's less then 120 sec - sleep for the remining time.

please help me.........
 
author & internet detective
Posts: 42073
932
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ishita,
The first step is to find the UNIX commands for each of those steps. For example, can you find a command that gets the date? For the stored procedure, look at your database documentation for the command line calls.

You don't need to change the shell. The shell is declared in the first line of the script:
#! /usr/bin/ksh
 
Ishita Saha
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah - I have the commands and i am trying my hands on the same.

I run into a few questions like:

I am using something like:

1 START=$(date +%s)
2 remain=30
3 sleep $remain
4 END=$(date +%s)
5 DIFF=$(( $END - $START))
6 echo "it took $DIFF secs"
7 sqlplus -s user_id/PWD@host <<EOF>
8 exec stored_proc;
9 EXIT;
10 EOF

This logic may not seem to be much relevant but this in in draft version for now.
Now I need to perform while i am in SQL connection, but if i insert statements 1-6 inside 7-10. It gives me error for each of the command - not found error which is expected since they are not sql commands.

Can somebody tell me what should be the way to do this. Thanks.
 
This tiny ad is wafer thin:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic