Calculate application "not run" status


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calculate application "not run" status
# 1  
Old 11-21-2010
Calculate application "not run" status

My shell env is Ksh88 , I need export the "not-running" application name.

Code:
txt="abc001|abc002|abc003|abc004|xyz001|xyz002|cde004"

IFS=\|
app=""

for i in $txt
do
   appstatus  $i   # the command will return the status, 0 is not running, 1 is running
   if [[ $? == "0" ]] ; then
        # record the application names, I stuck here.
        # such as:   app= $app + $i 
   fi
done

if [[ "$app" != "" ]] ; then
   echo " Application[s] are not running:  $app"
fi

# 2  
Old 11-21-2010
try this:

Code:
#!/bin/ksh
set -A arr abc001 abc002 abc004

app=""
status=1
for i in ${arr[*]}
do
   appstatus  $i   # the command will return the status, 0 is not running, 1 is running
   if [[ $? -eq 0 ]] ; then
      app=${app} " "  $i  
      status=0;
   fi
done

if [[ $status -ne 1 ]] ; then
   echo " Application[s] are not running:  $app"
fi

I was going to do more with the array, but this works as is.
# 3  
Old 11-22-2010
Thanks Jim.

I have to use: txt="abc001|abc002|abc003|abc004|xyz001|xyz002|cde004", because I need identify the application name in the same script. Please see my old post:

https://www.unix.com/shell-programmin...ify-input.html

I am using Chubler_XL's sulution in his first reply.

I will try your recommend.
Code:
      app=${app} " "  $i  
      status=0;

---------- Post updated at 10:20 AM ---------- Previous update was at 10:03 AM ----------

@ jim mcnamara

the command: app=${app} " " $i is not succesful.

I got error:


Code:
myscript[87]:  :  not found

And no application name export:

Code:
Appliation[s] name are:

---------- Post updated 11-23-10 at 09:08 AM ---------- Previous update was 11-22-10 at 10:20 AM ----------

Any suggestions?
# 4  
Old 11-24-2010
Ok, I fix it by myself.

Code:
app="${app} $i"

Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Shell Programming and Scripting

catalina.sh : need combination from "start" and "run"

heya, can someone help me with following problem. i am not sure how far you know the catalina.sh script from tomcat. when i start my tomcat with "catalina.sh run" then the startup-process-output will be printed out on the console, but the tomcat process is started in current shell/session, so... (1 Reply)
Discussion started by: Filly
1 Replies

5. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

6. UNIX for Dummies Questions & Answers

Run away "bootpgw" & "inetd"

Hello All. I'm get the following messages posted to the /var/adm/syslog file ever second and not sure on how to stop the process. May 14 15:50:52 a3360 bootpgw: version 2.3.5 May 14 15:50:52 a3360 inetd: /etc/bootpgw exit 0x1 As said about this gets logged every second only thing that... (4 Replies)
Discussion started by: cfaiman
4 Replies
Login or Register to Ask a Question