One Script on all the Unix flavors

Hi ,

I need to run a script on different flavors, namely

1) Linux
2) AIX
3) Solaris
4) HP-UX

Almost the entire script is the same except at a few places where commands specific to that OS are to be run. Is it possible to have a single script that runs on all the platforms?

Sth like this -

if(solaris)
{

execute this block of code

{

elif(hp-ux)
{

execute this block of code

}

How do i perform OS checking ?? Looking for inputs on this.

Thanks,
Praveen

use the command "uname -s" before performing "if" condition

-- Jayan Jayaseelan

[ X`uname` = XFreeBSD ] && echo 1 || echo 2;

Hi mirusnet,

Can you let me know what is the meaning of XFreeBSD ?

Thanks for your suggestion

Praveen

Command uname will be quite useful for you.

If you write using POSIX shell syntax, your script should run on all systems without any change and without needing to check the OS.

There are a few commands that may need changing, but they are rare.