UNIX basics Run Faster, Jump Higher, Finish First, Win The Gold

Slides:



Advertisements
Similar presentations
Program Management Portal: Overview for the Client
Advertisements

Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
“What do you want me to do now?”
Scheduling Discoverer Reports Scheduling Standard Reports Printing & Re-printing Standard Reports Focus on Reports Session 2 To print: Right click Choose.
TRACK 2™ Version 5 The ultimate process management software.
CS 497C – Introduction to UNIX Lecture 29: - Filters Using Regular Expressions – grep and sed Chin-Chih Chang
CS 497C – Introduction to UNIX Lecture 31: - Filters Using Regular Expressions – grep and sed Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
TRACK 3™ The ultimate process management software.
Filters using Regular Expressions grep: Searching a Pattern.
Chapter 8 Printing 1. In COBOL you send data to the printer by writing data to a file. In COBOL, the printer is defined as a file, and it is opened, closed,
Advanced File Processing
Using the Unix Shell There is No ‘Undelete’. The Unix Shell “A Unix shell is a command-line interpreter or shell that provides a traditional user interface.
1 TAC2000/ IP Telephony Lab Advanced Linux Administration Language: Offered in English Instructor: Dr. Quincy Wu (
1 Guide to Novell NetWare 6.0 Network Administration Chapter 12.
System Programming Regular Expressions Regular Expressions
Exam Revision. Exam Details Time 90 minutes (1hour 30 minutes). Six questions! How long per question? Five parts per question. How long for each part?
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
1 CA201 Word Application Increasing Efficiency Week # 13 By Tariq Ibn Aziz Dammam Community college.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
Selecting, Formatting, and Printing a finished Report…….
1 Lecture 5 Additional useful commands COP 3353 Introduction to UNIX.
1 Day 5 Additional Unix Commands. 2 Important vs. Not Often in Unix there are multiple ways to do something. –In this class, we will learn the important.
Perl and Regular Expressions Regular Expressions are available as part of the programming languages Java, JScript, Visual Basic and VBScript, JavaScript,
Chapter Five Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command.
Before we start…Getting Started. UST Outline History Getting Started Basic commands (command line) Operations on Files and Directories Input and Output.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
BIF713 Additional Utilities. Linux Utilities  You have learned many Linux commands. Here are some more that you can use:  Data Manipulation (Reg Exps)
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
I/O Redirection and Regular Expressions February 9 th, 2004 Class Meeting 4.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
I/O Redirection & Regular Expressions CS 2204 Class meeting 4 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
FILTERS USING REGULAR EXPRESSIONS – grep and sed.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Unix tools Regular expressions grep sed AWK. Regular expressions Sequence of characters that define a search pattern banana matches the text banana
Scripting (Just one of many tools.) P. Bailey. No, not this kind of scripting….  I wanted to find some cool graphics on scripting and I got….
Maximal D-segments Maximal-scoring No subsegment has higher score No segment properly containing the segment satisfies the above No supersegment has higher.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/9/2006 Lecture 6 – String Processing.
Creative Create Lists Elizabeth B. Thomsen Member Services Manager
PROGRAMMING THE BASH SHELL PART III by İlker Korkmaz and Kaya Oğuz
Regular Expressions Copyright Doug Maxwell (
Lesson 5-Exploring Utilities
UNIX UNIX tools Automating LIS Administration
Solving Real-World Problems with Wireshark
CS 330 Class 7 Comments on Exam Programming plan for today:
Looking for Patterns - Finding them with Regular Expressions
CST8177 sed The Stream Editor.
Topics Introduction to Repetition Structures
Unix Scripting Session 4 March 27, 2008.
PROGRAMMING THE BASH SHELL PART IV by İlker Korkmaz and Kaya Oğuz
How to… Use Crontab for SFX
Intro to PHP & Variables
What is Bash Shell Scripting?
The ‘grep’ Command Colin Masterson.
Register training Using the college register system
Guide To UNIX Using Linux Third Edition
Lecture 5 Additional useful commands COP 3353 Introduction to UNIX 1.
Unix Talk #2 (sed).
Chapter Four UNIX File Processing.
The MANY faces of Mrs. G….
Introduction to Bash Programming, part 3
Lecture 5 Additional useful commands COP 3353 Introduction to UNIX 1.
Review.
Presentation transcript:

UNIX basics Run Faster, Jump Higher, Finish First, Win The Gold Introduction to UNIX scripts that can make IT support easier, faster and more efficient. Speedy UNIX tools for searching and formatting. Real World problems and winning UNIX solutions IT Support on Roids Automated scripts do the work for you. Corbin Ellsaesser SNUG Vice President Sr. IT Systems Engineer Christiana Care Health Systems Delaware cde@christianacare.org

zz Z Did someone say UNIX ? Programming??

Did someone say UNIX ? Purpose of this session: To open your eyes to new possibilities. Demonstrate ways we use UNIX scripts to make LIS support easier. NOT to teach you how to program in UNIX.

Soft Error Logs Raise your hands If you . . . Love that they are cumulative for a month? Love that they are packed with such useful information? Search the logs looking for issues to resolve before they become problems? Go through the error logs daily? Only go to the logs after a problem has been brought to your attention? So the rest of you are like …

Soft Error Logs

Let UNIX Run the Race. How would you like to be emailed error log reports? Error Log Examples

Let UNIX Carry the Torch And email you a daily report The script only reports significant errors that were logged since the last report was sent. UNIX emails the report our team at 0700 each day. Monday’s report works weekends! It reports errors from Friday through Monday. Tuesday through Friday reports cover yesterday through today. A blank report means no errors to work up.

Print Queue Maintenance How do you monitor and maintain your printer queues? How often do you check printer queue statuses? Do you leave it to the users to report or fix their own? Do you print to doctor’s offices? Autoreports? What do you do if the office is closed on extended holiday? Printer jobs queue up because it’s out of paper/toner? Do their print jobs purge before they can print? How do you know if the report actually printed? What do you do? Wait for doctors to call for reprints?

Pass the Baton to UNIX. Schedule Maintenance on Cron Automatically check and restart stopped queues every 15 minutes “touch” unprinted files so they won’t ever purge until they print. touch command  changes file’s system date to “now” so Soft won’t remove it. Email report to Lab Admin Team once an hour, during business hours, for queue problems. Won’t ping Running but not printing Down queues Sample report.

Make UNIX Jump the Hurdles. Scripts do the heavy lifting for you. Scripts can : Automate searching, extracting and reformatting interface trace file records. Automate billing file searches Scrub PHI from data to attach to Tasks Do hosparm setting searches

Make UNIX Jump the Hurdles. Demonstrations Note: Our HIS system is Cerner PowerChart also known as HNAM Our HIS financial system is Soarian ADT message troubleshooting the hard way Missing BMP troubleshooting Scrubbing information to attach to Tasks Billing file troubleshooting

So tell me more about this “UNIX” stuff. What does it look like? How does it work? How hard is it to use?

So What does UNIX look like? grcv script to search RCV log is only about 18 lines long! #! /usr/bin/ksh Rcv="$UDIR/db/dat/I/HIS/RES*/rcv.trace" sed -e '/\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\)\.\ Program=</,/rq_Open(<hislisMAIN>)\ OK/d' \ -e '/^.*|ACK|.*$/,/^.*\\r>$/d' \ -e '/^\ ---/d' \ -e '/r.*\.\.\.$/d' \ -e '/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) .*len=[0-9]*$/d' \ -e '/^<.*>$/d' \ -e 's/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) \ .*\(MSH.*$\)/<r>\\r\1\2\3\\r\\r\4/g' $Rcv | perl -lne 'if (/<r>/){printf "\n$_"} else {printf} END{print}' | sed 's/\\r\\28\/>\ len=[0-9]*$//g' | grep -hE "$1" | sed -e 's/\\r/\ /g' \ -e 's/<r>//g' exit  sed -e '/\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\)\.\ Program=</,/rq_Open(<hislisMAIN>)\ OK/d' \ -e '/^.*|ACK|.*$/,/^.*\\r>$/d' \ -e '/^\ ---/d' \ -e '/r.*\.\.\.$/d' \ -e '/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) .*len=[0-9]*$/d' \ -e '/^<.*>$/d' \ -e 's/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) \ .*\(MSH.*$\)/<r>\\r\1\2\3\\r\\r\4/g' $Rcv |

I know what you’re thinking . . You’re right... This is our top UNIX script Programmer . .

UNIX manipulates text like Michael Phelps treads water.. Two basic commands and a fair knowledge of UNIX Basic Regular Expressions (BRE) are all you need. grep – Globally search a Regular Expression and Print. sed – Scripting with the “ED” UNIX editor. For the real propeller heads – awk is a great UNIX language to learn

Basic/Extended Regular Expressions A.k.a. BRE and ERE Regular Expression Metacharacters " ' \ UNIX quotation marks • (dot) Any single character ( similar to ? In Windows) [Ttrack] Square Brackets: Use any single character within the brackets [^Javelin] Caret in brackets: NOT any single character within brackets ( ) Three uses: 1: Used to enclose an "OR" expression sequence – (track|field) 2: Grouping for quantifiers (drunk)? (saloon girl)+ (cow)* 3: Create numbered expressions to be recalled later (see '\1' below) ? Previous expression is optional (repeat zero or more times) + One or more of the previous expression * Repeat Zero to Any number of the previous expression NOTE: Matches as many as possible to the end of document | “OR” (ABC|123) matches strings "ABC" or "123" ^ Start of line $ End of line \1 (\2 \3…) Output numbered expression created above (see '( )' above).

Let’s make sense of the Gym Monkey’s script grcv script: sed -e '/\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0- 9]\{3\}\)\.\ Program=</,/rq_Open(<hislisMAIN>)\ OK/d' \ -e '/^.*|ACK|.*$/,/^.*\\r>$/d' \ -e '/^\ ---/d' \ -e '/r.*\.\.\.$/d' \ -e '/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) .*len=[0-9]*/d' \ -e '/^<.*>$/d' \ -e 's/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) \ .*\(MSH.*$\)/<r>\\r\1\2\3\\r\\r\4/g' $Rcv | perl -lne 'if (/<r>/){printf "\n$_"} else {printf} END{print}' | sed 's/\\r\\28\/>\ len=[0-9]*$//g' | grep -hE "$1" | sed -e 's/\\r/\ /g' \ -e 's/<r>//g' exit

Now I get it! Remember those funny numbered expressions? sed -e '/\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\)\.\ Program=</,/rq_Open(<hislisMAIN>)\ OK/d' \ -e '/^.*|ACK|.*$/,/^.*\\r>$/d' \ -e '/^\ ---/d' \ -e '/r.*\.\.\.$/d' \ -e '/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) .*len=[0-9]*$/d' \ -e '/^<.*>$/d' \ -e 's/^\([0-9]\{2\}:\) \([0-9]\{2\}:\) \([0-9]\{2\}\.[0-9]\{3\}\) \ .*\(MSH.*$\)/<r>\\r\1\2\3\\r\\r\4/g' $Rcv | perl -lne 'if (/<r>/){printf "\n$_"} else {printf} END{print}' | sed 's/\\r\\28\/>\ len=[0-9]*$//g' | grep -hE "$1" | sed -e 's/\\r/\ /g' \ -e 's/<r>//g' exit

UNIX grcv script has 4 parts sed -e '/\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\)\.\ Program=</,/rq_Open(<hislisMAIN>)\ OK/d' \ -e '/^.*|ACK|.*$/,/^.*\\r>$/d' \ -e '/^\ ---/d' \ -e '/r.*\.\.\.$/d' \ -e '/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) .*len=[0-9]*$/d' \ -e '/^<.*>$/d' \ -e 's/^\([0-9]\{2\}:\)\([0-9]\{2\}:\)\([0-9]\{2\}\.[0-9]\{3\}\) \ .*\(MSH.*$\)/<r>\\r\1\2\3\\r\\r\4/g' $Rcv | perl -lne 'if (/<r>/){printf "\n$_"} else {printf} END{print}' | sed 's/\\r\\28\/>\ len=[0-9]*$//g' | grep -hE "$1" | sed -e 's/\\r/\ /g' \ -e 's/<r>//g' exit

Disclaimer: No Trace Files were harmed by running any script. Original files are untouched. Scripts work by reading the file into a data stream and manipulating the flow. Scripts can output to the screen, a file, an email, a printer – anywhere you want to send them. Step by step what the grcv script does

Questions? Bring home the Gold

References