wood burning stoves
The moose likes Linux / UNIX and the fly likes Ksh script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Ksh script" Watch "Ksh script" New topic

Ksh script

Ishita Saha
Ranch Hand

Joined: May 30, 2007
Posts: 39
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.........
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

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

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Ishita Saha
Ranch Hand

Joined: May 30, 2007
Posts: 39
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;
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Ksh script
jQuery in Action, 3rd edition