05-23-2008
scripting newbie needs help
I have written a script that will email a generic user when a device is "offline". I would like to enhance this by having the script lookup a contact's email and automatically add it to the MAIL_LIST. I am trying to lookup and return data based on a field common in two files
File 1 /optim/ais_scripts/files/offline/offline_readers.txt:
0150 PU SA Handheld 200-03
File 2 ; /optim/ais_scripts/files/bb_unit_contacts.txt
0150,contact name,contact@princeton.edu
#This script will email ais psig group any Active and Offline readers by loop and reader address, location number, location name.
#
#SCRIPT:mail_offlines
#
#revised:5/23/2008 dtierney
#
MAIL_FILE=/optim/ais_scripts/files/offline/offline_readers.txt
MAIL_LIST="generic_user@princeton.edu"
/optim/bin/read_shm > /optim/ais_scripts/files/offline/readers.status
rm /optim/ais_scripts/files/offline/offline_readers.txt
echo " LOC# Reader Name LP#-AD" >> /optim/ais_scripts/files/offline/offline_readers.txt
echo "----------------------------------------" >> /optim/ais_scripts/files/offline/offline_readers.txt
for j in `/optim/bin/parse_shm | grep "ACTIVE Off-Line" | awk '{ print substr($0,1,6) }'`
do
cat /optim/ais_scripts/files/offline/readers.status | grep "$j" | awk '{ print substr($0,15,4) substr($0,32,31) substr($0,1,6) }' >> /optim/ais_scripts/files/offline/offline_readers.txt
done
echo "------------------------------------------------------------------">> /optim/ais_scripts/files/offline/offline_readers.txt
mailx -s "Offline Readers" $MAIL_LIST < $MAIL_FILE
rm /optim/ais_scripts/files/offline/offline_readers.txt
echo "email has been sent"
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi there,
I am a student and currently working on a project. I have a file that contains about 50 filenames. (1.txt, 2.txt, 3.txt ...).
I would like to know how can I store these filenames into a variable using a loop?
I would appreciate if anyone can help me. Thank You.
Regards,
Bib (4 Replies)
Discussion started by: coolbib
4 Replies
2. UNIX for Dummies Questions & Answers
I'm relatively new at this scripting game, just need to learn some basic stuff for data handling.
My current need is to write a script that loops through a textfile of filenames, and for each file removes the first line and re-writes that file to a new name.
In fact I could do with knowing... (1 Reply)
Discussion started by: mattyjim2
1 Replies
3. Shell Programming and Scripting
Seems simple but I am having difficulty with this one: I am trying to write a single command line argument (which will be a path) - the program should print out the owner of the path.
I can not get anything I write to run.
Please help. (5 Replies)
Discussion started by: Kymmers7
5 Replies
4. Shell Programming and Scripting
hi all,
i am just getting in to bash scripting, so don't be too harsh...
i've created this little backup script, and it's just awfull... ugly, doesn't work like I want it to, the works. anyways, i was hoping some of you might help me improve it and learn a little in the process.
what i... (13 Replies)
Discussion started by: jmd9qs
13 Replies
5. Shell Programming and Scripting
Could someone please recommend a very good shell scripting book for me. I would be starting a new job that would require a very good understanding of shell scripting. Please help. (3 Replies)
Discussion started by: ayoka
3 Replies
6. Shell Programming and Scripting
Hi,
I am newbie in shell scripting
I have a file name like simple.txt which comes from Mainframe systems onto windows dir every 15 minutes daily. File name is same. Every 15 minutes it updates.
I need to write shell script to check if the file arrived every 15 min or not.
If the new file... (4 Replies)
Discussion started by: chinniforu2003
4 Replies
7. Shell Programming and Scripting
Hi Guys, I want to create a shell script to run multiple jobs in sequence.
Explaination -
If I were to run each jobs individually I would have gone to folder - "abin"(where my shellscript is place) as follows
cd abin
abin > runappeng.sh abc001
Now, I have list of programs which are like... (8 Replies)
Discussion started by: chaits84
8 Replies
8. Shell Programming and Scripting
Howdy folks,
I'm trying to craft a log file summarisation tool for an application that creates a lot of duplicate entries with only a different suffix to indicate point of execution. I thought I'd gotten close but I'm clearly missing something.
Here's a genericized version:
A text_file... (3 Replies)
Discussion started by: mthespian
3 Replies
9. Shell Programming and Scripting
Hi all,
I have drill to do and I'll very appreciate your help:
Please create a simple CSV file as follow (3 columns and 4 rows):
A,B,C
A,”B,C”,D
“A,B”,C,D
o A,B,”C,D”
- Please refer to the comma between the quotation marks as a parameter and not as a separator.
- Please provide... (3 Replies)
Discussion started by: elior
3 Replies
10. Shell Programming and Scripting
Please bear with me, I'm a beginner but have had some experience and decent knowledge to understand things as I read them and I'm in the process of trying to learn more. I recently inherited a UNIX server which has a bash script which is part of a crontab schedule that needs to be modified (or... (3 Replies)
Discussion started by: Danylko
3 Replies
LEARN ABOUT OPENSOLARIS
stmfofflinetarget
stmfOfflineTarget(3STMF) SCSI Target Mode Framework Library Functions stmfOfflineTarget(3STMF)
NAME
stmfOfflineTarget - take offline a target port that is currently in the online state
SYNOPSIS
cc [ flag... ] file... -lstmf [ library... ]
#include <libstmf.h>
int stmfOfflineTarget(stmfDevid *target);
PARAMETERS
target The identifier of the target port to offline.
DESCRIPTION
The stmfOfflineTarget() function takes offline a target port that is currently in the online state. Once in the offline state, the target
port will no longer be capable of servicing requests in the system.
This API call can be used to take offline a target port device for servicing. Once the target port is offline, it will no longer be avail-
able to any entities outside of the SCSI Target Mode Framework. Any initiator ports that currently have sessions established by the
offlined target port will be logged out.
RETURN VALUES
The following values are returned:
STMF_ERROR_BUSY The device is currently busy.
STMF_STATUS_SUCCESS The API call was successful.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|MT-Level |Safe |
+-----------------------------+-----------------------------+
SEE ALSO
libstmf(3LIB), attributes(5)
SunOS 5.11 9 Jun 2008 stmfOfflineTarget(3STMF)