image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #9  
Old February 22nd, 2004, 08:25 PM
WeeZer51402's Avatar
Right 00.1% of the Time
 
Join Date: Dec 2002
Location: Lost in my own unintelligible ramblings
Posts: 473
Thanks: 0
Thanked 0 Times in 0 Posts
WeeZer51402 is on a distinguished road
what are you looking to do with this script? what you like it to show?
__________________
ON THE WAY:
15" PB 1.67|100|1024 --- 10.4
------------------------------------------
17" iMac G5 1.8|80|512|BT --- 10.3.9
FrankenMac G4 500|55|640 --- 10.3.9
PowerMac 9600 300|4|512 --- 1.2
eMachine 500is 500|4.3|196 --- OpenStep 4.2
Server 2.3|260|512 --- FedoraCore
Reply With Quote
  #10  
Old February 22nd, 2004, 09:24 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
Initially, I wanted a script to extract from a file that I name, the size of the file and last time it was modified. Then I remembered that someone posted a command line equivalent to "Get Info" in the Finder. I've searched the forums and can't find the thread. I thought I could piece some code together to do what I need it to do. I just need a script to determine whether or not a text file has anything in it, if it does, then the script needs to check the last time it was modified, let's say 20 minutes. If the file is empty, the script does nothing, other than check the text file again in 20 minutes via running as a cron job. The reason I'm doing this is for a project at work. Part of my job is to maintain four Open Access (anyone can use the equipment) NMR laboratories. The Varian NMR instruments (http://www.varianinc.com/cgi-bin/nav...&cid=IJQMIQJFO) are controlled by Sun Microsystems workstations running Solaris 8. These instruments are completely automated (http://www.varianinc.com/cgi-bin/nav...&cid=IJQMIJLFP) with very fast robotics. A previous employee wrote a series of shell scripts that does quite a bit more, sorry I don't want to say what they do for fear of breach of confidentiality. Pharmaceutical companies are very protective of methods developed in-house to streamline, make research more efficient, and less costly. Occasionally, this Varian software just silently stops running and no experiments are running-that costs A LOT OF MONEY WHEN THEY SIT IDLE, I suggested to my supervisor that a shell script be written that runs as a cron job to check a text file over a specified time frame. The script's job is to detect when the Varian automation software and hardware hangs up. Code already exists in other shell scripts on what to do when an error occurs.

Late Friday afternoon my supervisor said that if I can't write the code, he can find someone who can, he just needs from me a logic diagram of the program to give to someone else. And I can't post a diagram here without giving away other parts of the custom shell scripts that do everything else. I'm stuck between a rock and a hard place. I don't want to depend too much on other people, because this is a good learning experience, and I want to do as much of it myself as I can. I like programming, I just don't know enough about C/C++ or shell scripts.

About 14 years ago, I wrote a report generator for the hospital department I was working in, to finance my college education. The medical reports up to that time were recorded on dictation equipment, and a secretary had to listen to the dictation cassettes and type EVERYTHING on the tape. I said "I can make this whole process much more efficient", not even knowing if I could do it. One year later, a magnificent series Word Perfect Macros, the "Report Generator" was completed. My supervisor implemented it, report turn-around times decreased substantially, reports were made more efficiently, Vice Presidents were notified, and hospital programmers used my Report Generator as a model for other departments. In the end, I got an excellent job review, a letter of commendation placed in my employee file, and I was the "wiz kid" of the department until I left.

Last edited by chemistry_geek; February 22nd, 2004 at 09:33 PM.
Reply With Quote
  #11  
Old February 26th, 2004, 05:10 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
sdeleurme is on a distinguished road
simple cron job

hey, put the following code into a file called checkq.sh.


Code:
#!/bin/bash 

el1=`cat lastenterq`
dl1=`cat lastdoneq`

# this assumes you are only looking for line changes.  not changes in lines.  
# use bin/diff for that 
el0=`wc -l enterq|awk '{print $1}'`
dl0=`wc -l doneq|awk '{print $1}'`

# of  course, you prolly want to get an email or something. 
if [ $dl1 == $dl0 ] ; then echo "Done q has not changed in 20 minutes" ; fi
if [ $el1 == $el0 ] ; then echo "Enter q has not changed in 20 minutes" ; fi

echo `wc -l doneq|awk '{print $1}'` > lastdoneq
echo `wc -l enterq|awk '{print $1}'` > enterdoneq
then add this to your crontab by doing "crontab -e"
Code:
0,20,40 * * * * checkq.sh
make sure your paths are good ... and chmod +x checkq.sh and you should be good to go. oh, this will run on any *nix os i figure.


Quote:
Originally Posted by chemistry_geek
I need help with creating a shell script for a project at work. I know this doesn't have anything to do with Macs, but I need a little direction to get this project going.

I just need to know when two text files "enterQ" (gets smaller over time) and "doneQ" (gets larger over time) haven't changed in 20 minutes.

Any help would be greatly appreciated! I just need to be pointed in the right direction to get this project started. I have a UNIX Shells book at work, but it is old. I'm working with Sun workstations running Solaris 8.

Last edited by sdeleurme; February 26th, 2004 at 05:11 PM. Reason: forgot about solaris
Reply With Quote
  #12  
Old February 26th, 2004, 06:32 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
Thank you very much for the reply. I will give this script a try. I learned earlier this week that Solaris uses the Bourne shell, don't know if that makes a difference. Prolly so. Also, I been thinking of some other features to add to the script in which case this shell script project will likely be handed off to one of the site programmers.
Reply With Quote
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 08:52 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.