|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
Another Crontab question or maybe scripting
I've looked through several pages of the forums but do not see where this question has come up before. I need to pass some variables into a script via a cron job, then have the cron insert the variables into the script. The script takes in serveral values five to be exact. Then replaces the inputed values into a Oracle Script and outputs a list which is emailed to several users. The script runs great from the command line. I just need a cron to keep one of our VP's from asking me for this info ten times a day ;-) and I'm getting a little tired of running it like I have nothing else to do all day and night.
Anyway got another tip to try filename value1 value 2 .... The script ran but of course did not get the values so the oracle script bombed. Here is how I read my variables echo "....... (This will be the one we report on): ";read TERM5; export TERM5 echo "Term 4: ";read TERM4; export TERM4 echo "Term 3: ";read TERM3; export TERM3 echo "Term 2: ";read TERM2; export TERM2 echo "Term 1: ";read TERM1; export TERM1 Tried to get rid of the echos and even the read, but it bombed from the command line so I know it will not work from cron. Does any one have any ideas on how I can get these variables to read properly without my typing them in? |
|
#2
|
|||
|
|||
|
what should this do
>>>>>> echo "....... (This will be the one we report on): ";read TERM5; export TERM5 i know, it looks strange, but the way: 1) export the variables # you just reserve names #!/bin/sh export AAA1 AAA2 AAA3 AAA4 .... 2) give them values AAA1="abcdef" AAA2="aa bb cc dd ee ff" .... 3) put this all in a file, say 'myjobvalues' 4) in cron, call 'startmyjob' 5) in 'startmyjob' put #!/bin/sh . myjobvalues # note the dot in front, that will load AAA1 AAA2 ... dosomethingwith $AAA1 $AAA2 .... |
|
#3
|
|||
|
|||
|
I actually thought of adding them to a file, but was not sure how to read them into my second file. Did not think of the export. Looking back at this I really did not descibe this very well, guess I was tired last night. The TERM5, etc., are values that are currently typed in when the script runs. Then they are passed into an Oracle query, the result is dumped to a list then the list is emailed to certain users. This works like a top.
My problem is that one of the VP's is asking for this list four or five times a day. Instead of opening up the Banner app and pulling the info he would rather I do it all. I don't have time to constantly run the scripts all day as I have a few other items to take care, like keeping the DB up. ;-) I could add the Terms in manually to the script, but that defeats my long term goal of never touching this script again unless there is a schema upgrade. I was thinking if I could find a way to dynamically insert the values, then maybe I could find a way to dynamically change the values based on date as I know when the quarters start and end, for several years out. Thinking about your export suggestion. Its possible that I write another script to pull the current term out of the DB, then cacluate the four previous terms and then dynamically replace the variables in the second file, by exporting. I'll need to think some more, but you've got me thinking here now. I could proably jsut add the script to pull the term in fornt of the current script then pass those varialbles to the second. Looks like I need to dig out the PL/SQL book as this will probably turn out to be more elegant than my original thoughts. Bruce |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Another Crontab question or maybe scripting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|