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
Solved

An easy 50 pointer - hopefully :)

Posted on 2002-04-18
2
227 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is the meaning of filesystem loop detected? 7 1,146
sudo logging 5 101
Ubuntu install gnome-session-fallback is failing 4 114
Linux performance issues with 100% swap usage, etc 15 94
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.

860 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