Re: Scripting
- From: Chris Elvidge <chris.elvidge@xxxxxxxxxxxxxxxx>
- Date: Mon, 31 Dec 2007 09:44:24 +0400
Calab wrote:
Looking to create a small script that will process the output of one command and run another command
Output looks like this
38914 - system1 online -
38915 - system1 online -
38922 - system1 online -
11013 - system2 offline -
21914 - system3 busy -
21916 - system3 busy -
20355 - system4 offline -
If I recieved the above output, I'd want to run the following commands
syscheck system2
syscheck system4
This should be simple to do, but I've not got a clue how to script on a Linux PC.
Any pointers? Suggestions?
Thanks!
#!/bin/bash
for i in $(command)
do
j=$(echo "$i" | cut -f4)
k=$(echo "$i" | cut -f3)
[ "$j" = "busy" ] && syscheck "$k"
done
#
where "command" gives your table, "cut" assumes tabs are the column delimiters. - man cut
HIH
--
c.e@xxxx
.
- Follow-Ups:
- Re: Scripting
- From: Calab
- Re: Scripting
- From: Calab
- Re: Scripting
- References:
- Scripting
- From: Calab
- Scripting
- Prev by Date: Scripting
- Next by Date: Re: Scripting
- Previous by thread: Scripting
- Next by thread: Re: Scripting
- Index(es):
Relevant Pages
|