Solved

An easy 50 pointer - hopefully :)

Posted on 2002-04-18
2
231 Views
Last Modified: 2010-04-21
Hi,

I'm writing a simple script and am having trouble with wildcards and string searching.

OK, my problem:

I have a script already called "lpck" which polls a pre-defined list of printers and executes the lpstat... command against them to see whether they are up and printing or down.

What I want my new script to do, is assign a variable to the output of the lpck script (easy part):

the_output=`lpck`

Then I want to search the_output for the word "DOWN" which will indicate that one of my printers is not functioning.

Now, I know how to test for numbers etc using the if ... then ... loop, but how do I say:

If [ "whatever the output from lpck is" matches "anything DOWN anythng" ]
then......

else.....

I guess I need to use some sort of wildcard, although I've tried this:

if [ "$printstats" = "*DOWN*" ]

And it doesn't work.

Oh, I'm running AIX 4.3 and AIX 4.2 by the way, both on RS6000's.

Thanks in advance.

Neil.
0
Comment
Question by:NTIVER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
ecw earned 50 total points
ID: 6950209
in ksh ...
  if [[ "$printstats" = *DOWN* ]]
or in ksh/sh
  if echo "$printstats" | grep DOWN > /dev/null
0
 
LVL 1

Author Comment

by:NTIVER
ID: 6950430
ecw - you're first example works beautifully - many thanks.

I thought I was close :-)

Cheers.

Neil
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question