Computing.Net > Forums > Unix > SHell scripting

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

SHell scripting

Reply to Message Icon

Name: burchracer
Date: June 18, 2009 at 14:54:39 Pacific
OS: AIX535
Subcategory: Software Problems
Comment:

I'm new to Scripting and I'm trying to validate several of the network tunable variable to see if it matches our correct setting and then pass or fail the test script.The command I can run from command line is :
no -a |grep tcp_ndebug
which returns
tcp_ndebug = 100
the value in this case is correct and the test would pass.
ANy direction in this would be greatly appreciated. I do know these values are found in a file, and I've been experimenting with pulling it from the file and comparing it, but was hoping a script could do it quicker and more efficient.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: June 18, 2009 at 15:54:38 Pacific
Reply:

I am assuming that executing

no -a |grep tcp_ndebug

actually returns

tcp_ndebug = 100

In as script, use command substitution to return the results to a variable:

# I am using the Korn shell, ksh
var=$(no -a |grep tcp_ndebug)

# the set command parses your string into command line arguments:using the equal sign

# IFS is the field seperator
set - $(IFS="="; echo ${var})

# the second field now contains 100.

# do a check with an if statement:
if [[ $2 -eq 100 ]]
then
   echo "it passes"
else
   echo "No, it does NOT pass"
fi

Let me know if you have any questions


0

Response Number 2
Name: ghostdog
Date: June 19, 2009 at 03:18:03 Pacific
Reply:

just use awk

no -a | awk -F"=" '/tcp_ndebug/ && $2+0==100{print "ok"}'

GNU win32 packages | Gawk


0

Response Number 3
Name: burchracer
Date: June 24, 2009 at 11:22:09 Pacific
Reply:

Thank you both for your assistance. I tried both methods and you have helped tremendously.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: SHell scripting

Shell Scripting www.computing.net/answers/unix/shell-scripting/8475.html

Variables in Shell SCripting www.computing.net/answers/unix/variables-in-shell-scripting/6020.html

shell script to uninstall java www.computing.net/answers/unix/shell-script-to-uninstall-java-/5976.html