File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ksh script

 
Ishita Saha
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • 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.........
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33699
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic