Version checking


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Version checking
# 8  
Old 09-03-2018
Now with little modification it work perfectly! Smilie Thank you
but have two question:
1-is it possible to set name for head columns?
2-in each config file wrote state, it it possible to show those state in new column like this:


No......config name......version......state
1...........config1...........2.7.........state1
2...........config2...........4.9.........state2
3............config3..........1.2.........state3


Thanks,

Last edited by indeed_1; 09-03-2018 at 12:24 AM..
# 9  
Old 09-03-2018
1) yes, for example you can simply echo the header line before the ps | while-do-done.

2) yes

Everything is possible. But cannot provide anything if you do not provide examples.
# 10  
Old 09-03-2018
Sure this is example of my config1 file:

Code:
State = off
Hostname = rhel
Ip = 192.168.10.10

I want to show this items in the table like this:

Code:
No......config name......version............state.............ip.................hostname
1...........config1...........2.7...........off...........192.168.10.10..........rhel
2...........config2...........4.9...........on............192.168.10.11........ubuntu
3...........config3..........1.2............off...........192.168.10.12..........rhel

this code will made columns 1 2 3:
Code:
 #!/bin/sh
 cnt=0 ps -eo args | while read prog args
 do   

case $prog in   (*app);;   (*)     

continue;;   

esac   

ver=$("$prog" -version </dev/null)   

echo "$((cnt+=1)) $prog $ver $args" 

done


Last edited by indeed_1; 09-04-2018 at 05:00 AM..
# 11  
Old 09-04-2018
You can process a config file like this, put in a function:
Code:
readconfig(){
  # set state, hostname, ip
  while IFS=" =" read confkey confval
  do
    case $confkey in
    ([Ss]tate) state=$confval;;
    ([Hh]ostname) hostname=$confval;;
    ([Ii]p) ip=$confval;;
    esac
  done
}

You have given my script proposal that certainly needs some adaption.
YOUR version would be more helpful.
But maybe you can help yourself with the following information.
Once you have defined the readconfig function in your script, and once you have the pathname of a config file in a variable, say config, then you can call the function like this
Code:
  readconfig <$config

and then you have set the variables state, hostname, ip that you can echo out as $state, $hostname, $ip.
# 12  
Old 09-05-2018
I try below code, but give me this error : ./script.sh: line 14: -bind /home/config: No such file or directory.
I think it is related to output of this command "ps -eo args",
"-bind /home/config"
consider "-bind" as argument, if I able to define only address of config file problem will be fix but i have no idea how can I extract only address of config file and suppress "-bind" !



Code:
#!/bin/sh
cnt=0
ps -eo args |
while read prog args
do
type=""
  case $prog in
  (*app);;
  (*)
    continue;;
  esac
 ver=$("$prog" -version </dev/null)

readconfig < $args
readconfig(){
  # set state, hostname, ip
  while IFS=" =" read confkey confval
  do
    case $confkey in
    ([Ss]tate) state=$confval;;
    ([Hh]ostname) host=$confval;;
    ([Ii]p) ip=$confval;;
    esac
  done
}

echo $confkey $confval $state $hostname $ip


Last edited by indeed_1; 09-05-2018 at 06:13 PM..
# 13  
Old 09-06-2018
Try
Code:
read prog TMP args

so -bind will be read into the TMP variable.
# 14  
Old 09-06-2018
thank you this part run correctly and output are exact address. when i echo "$args" print address "/home/config", but part two not work correctly!

Code:
#!/bin/sh
cnt=0
ps -eo args |
while read prog tmp args
do
type=""
  case $prog in
  (*app);;
  (*)
    continue;;
  esac
 ver=$("$prog" -version </dev/null)


but this part not run and give me this error : ./script.sh: line 14: readconfig: command not found

Code:
readconfig < $args
readconfig(){
  # set state, hostname, ip
  while IFS=" =" read confkey confval
  do
    case $confkey in
    ([Ss]tate) state=$confval;;
    ([Hh]ostname) host=$confval;;
    ([Ii]p) ip=$confval;;
    esac
  done
}

echo $confkey $confval $state $hostname $ip

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

OS version and Firmware version

Guys, How to find OS version and firmware version in LINUX? Like in AIX. uname -a will show me the version 5.3, 6.1,7.1. lsmcode -c will show me - system firmware image as SF240_417. What are the similar commands in Linux. I checked uname -a and cat /etc/release. uname... (1 Reply)
Discussion started by: ElizabethPJ
1 Replies

2. AIX

Checking xlc compiler version

Hi, Below is output of lslpp command. bash-3.00# lslpp -L | grep xlC xlC.aix50.rte 11.1.0.1 C F XL C/C++ Runtime for AIX 5.3 xlC.cpp 9.0.0.0 C F C for AIX Preprocessor xlC.msg.en_US.cpp 9.0.0.0 C F C for AIX... (2 Replies)
Discussion started by: manoj.solaris
2 Replies

3. Shell Programming and Scripting

Copy a file from directroy/ prior version to the directory/ new version

How to copy a file from directroy/ prior version to the directory/ new version automatically. (4 Replies)
Discussion started by: roy1912
4 Replies

4. SCO

Stop boot system at "Checking protected password and checking subsystem databases"

Hi, (i'm sorry for my english) I'm a problem on boot sco unix 5.0.5 open server. this stop at "Checking protected password and checking subsystem databases" (See this image ) I'm try this: 1) http://www.digipedia.pl/usenet/thread/50/37093/#post37094 2) SCO: SCO Unix - Server hangs... (9 Replies)
Discussion started by: buji
9 Replies

5. UNIX for Advanced & Expert Users

Advanced Search * View * Edit JAVA version to WORK in GLASSFISH Forum topic JAVA version

Would like to confirm the ff. I got confused actually with the version I needed to download that will work on glassfish 3.0.1 a. Debian Squeeze (HP DL360). Need to use java version6 On Debian, I did apt-get install sun-java6-jdk. So when I check it's java version "1.6.0_22" Java(TM) SE... (1 Reply)
Discussion started by: lhareigh890
1 Replies

6. Solaris

Migrate unix version 8 to version 9

i have a program writing in PRO C which currently running in unix version 8 tie with oracle 8i, but in the future company gonna migrate this OS to version 9. Anything i have to prepare for my PRO C program to run in unix version 9? or anything would that impact my program couldn't run well? what... (2 Replies)
Discussion started by: lsy
2 Replies

7. AIX

checking the version revisions of a java file inside the ear using KSHELL in AIX.

consider on day1, in PVCS repository we have java files like a.java,b.java with version revision 1.0, through ANT build script we have compiled and created an ear,named c.ear in AIX build server.we have transfered this ear from build server to portal server through FTP using KSHELL. consider... (0 Replies)
Discussion started by: kareemaashik
0 Replies

8. UNIX for Dummies Questions & Answers

checking for non-zero value

I have a process that spits out a file called sqlplus.out, here is what the result looks like: Currently the value you see is zero, what I need to do is perform an action if that value is non-zero, so how do I check that value in an if statement? If it helps at this moment in development the... (6 Replies)
Discussion started by: philplasma
6 Replies

9. UNIX Desktop Questions & Answers

checking of GNU C Complier version

Hi, How do i check the GNU C Complier my system is running? thanks jennifer (2 Replies)
Discussion started by: jennifer
2 Replies
Login or Register to Ask a Question