Check & use output of svcs command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check & use output of svcs command
# 1  
Old 08-05-2013
Check & use output of svcs command

Hello Dear Friends,

I need to check output of svcs command and so the status of some instances.

Code:
-bash-3.00$ svcs -a | grep rfe
online         Aug_04   svc:/application/rfe/rfe_master_3:default
online         Aug_04   svc:/application/rfe/rfe_master_4:default

Code:
as you can see there are two instances and operation team needs to be sure that they are running (online). 
If there is a sporadic issue occurs and they becomes down (offline) then they need to be restarted & invoked.

I would appreciate if you could tell me how could I check those output lines, namely $1 of those rows.. Afterwards i will compare them in an "if" statement and then do the necessary actions.

I thought about using awk with getline (getting the outputs special variable of awk and then checking) however I know how to use getline by giving an output file but dont know how to give the output of the commands..

KR,
Eagle
# 2  
Old 08-05-2013
You can try something like this:
Code:
svcs -a | awk '!/^online/{print $NF " is " $1}'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Check output of command before outputing and keep exit code

so i have scripts that are piped and then run through one of the following mechanisms: cat myscript.sh | sh cat myscript.pl | perl what i want to do is, after either of the above commands are run, if the output from the command contains a certain string, i want it to avoid printing... (3 Replies)
Discussion started by: SkySmart
3 Replies

2. Shell Programming and Scripting

Different output for awk command on Linux & HP-UX

I am using an awk command to extract a particular portion of a string. Below is the command and its output on a Linux system: oracle@host1:/tmp (/home/oracle) $uname -a Linux host1 2.6.32-279.39.1.el6.x86_64 #1 SMP Fri Nov 15 05:38:26 EST 2013 x86_64 x86_64 x86_64 GNU/Linux ... (7 Replies)
Discussion started by: veeresh_15
7 Replies

3. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies

4. Solaris

svcs command shows the state as disabled

Hi I need to export a directory named /sybase from my solaris machine via NFS. The svcs command shows the state as disabled. Please let me know how to export the directory. Once the directory is exported from the solaris machine it has to be mounted locally in an aix machine. Can some one... (2 Replies)
Discussion started by: newtoaixos
2 Replies

5. Shell Programming and Scripting

Problem with call of Java Programm & return code handling & output to several streams.

Hello Everybody, thanks in advance for spending some time in my problem. My problem is this: I want to call a java-Programm out of my shell skript, check if die return code is right, and split the output to the normal output and into a file. The following code doesn't work right, because in... (2 Replies)
Discussion started by: danifunny
2 Replies

6. UNIX for Advanced & Expert Users

Need svcs equivalent command

Hi, I am new to HP-UX. Can someboby help me with the svcs equivalent command in HP-UX ??? svcs is command that we use in Solaris for service status. I need to get the status of services in HP-UX. Thanks in advance. (2 Replies)
Discussion started by: EmbedUX
2 Replies

7. Shell Programming and Scripting

manipulate & format the output of spool command

Hi All, I am spooling the data some sql queries into a single file but wanted to know how to format the data of the file generated by spool. #!/bin/sh unset -f USAGE USAGE () { clear echo "############################USAGE#######################\n" echo "Incorrect number of... (2 Replies)
Discussion started by: ss_ss
2 Replies

8. Shell Programming and Scripting

Net::SSH::Perl->Execute any unix command & display the output in a proper form

Net::SSH::Perl ...... how to print the output in a proper format my $cmd = "ls -l"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd("$cmd"); print $stdout; the script works fine, but i am unable to see the output... (2 Replies)
Discussion started by: gsprasanna
2 Replies

9. Solaris

svcs command on solaris 8 and 9

Hi, Can anybody tell me what is the command to start and stop services on solaris 8. I found command svcs on solaris 10 but not on 8 or 9. Please guilde me. Thanks, Rucha (7 Replies)
Discussion started by: rucha_mahajan
7 Replies
Login or Register to Ask a Question