Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell Script ..help

Status
Not open for further replies.

bas1080

IS-IT--Management
Sep 2, 2003
21
US
Hi,

It has been long time I have scripted something. Could somebody let me know to write a script where in I have to check the version of UNIX OS, e.g if the version of unix is SUN run the /usr/sbin/* and if it is UNIX run the /usr/...

Thanks in Advance
 
Code:
man uname
uname -s

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
What I want to do is I need to check the version of OS if it is Solaris then I need to run the command /usr/sbin/snmpd, if it is AIX then I need to run the command /usr/bin/startsrc –s snmpd. Could you please help on this.

Thanks in Avvance
 
Code:
#!/bin/ksh

[[ $(uname -s) = *Sun* ]] && echo 'I am Sun' || echo "I ain't no Sun"

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I usually have a portability section near the beginning of my scripts along the lines of:

Code:
case `uname` in
    SunOS)
        AWK=/usr/bin/nawk
        GREP=/usr/xpg4/bin/grep
        ;;
    Linux)
        AWK=awk
        GREP=grep
        ;;
    *)
        AWK=awk
        GREP=grep
        ;;
esac

# example usage
${AWK} 'some example awk script' somefile
ls -l | ${GREP} somestring

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top