UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old January 4th, 2005, 08:26 PM
dynamicvb dynamicvb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 45 dynamicvb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 40 m
Reputation Power: 5
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?

Reply With Quote
  #2  
Old January 5th, 2005, 06:11 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,078 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 14 h 28 m 26 sec
Reputation Power: 9
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 ....

Reply With Quote
  #3  
Old January 5th, 2005, 08:24 PM
dynamicvb dynamicvb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 45 dynamicvb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 40 m
Reputation Power: 5
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Another Crontab question or maybe scripting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway