Detect Operating System


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Detect Operating System
# 1  
Old 02-19-2013
Question Detect Operating System

Hi,

I need a script that needs to detect the Operating System and based upon wheter it is Linux, Solaris x86, Sparc, Itanium etc it should populate "ps" command with detailed output accordingly

for example:

Code:
ps -xef | grep java -> Itanium

Code:
ps -auxwww | greap java -> Solaris

# 2  
Old 02-19-2013
Try
Code:
uname

command to know about the version.
# 3  
Old 02-19-2013
Quote:
Originally Posted by Vikram_Tanwar12
Try
Code:
uname

command to know about the version.
I understand uname will do the job but I am not sure what and how to grep from the uname's output and i am not sure about the various ps command formats for various OSs.

Can you please help me with a short script ?
# 4  
Old 02-19-2013
You can try something like this

Code:
#!/bin/sh
v1=$(uname)
if [[ "$v1" = Linux ]];then
ps -ef | grep java
fi
else
echo "wrong option"
fi

Similarly by using
Code:
if statement

in loop you can try for other.

Last edited by Vikram_Tanwar12; 02-19-2013 at 09:06 AM..
This User Gave Thanks to Vikram_Tanwar12 For This Post:
# 5  
Old 02-19-2013
Quote:
Originally Posted by Vikram_Tanwar12
You can try something like this

Code:
#!/bin/sh
uname
if [[ uname -eq Linux ]];then
ps -ef | grep java
fi

Similarly by using
Code:
if statement

in loop you can try for other.
SunOS

HP-UX

Can you help list any more Operating Systems ?
# 6  
Old 02-19-2013
AIX and FreeBSD
This User Gave Thanks to Vikram_Tanwar12 For This Post:
# 7  
Old 02-19-2013
Quote:
Originally Posted by Vikram_Tanwar12
AIX and FreeBSD
Can you give me relevant ps statements for the mentioned OS [AIX and FreeBSD] ?

Last edited by mohtashims; 02-19-2013 at 10:26 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

What's my Operating System

Can we know the operating given the IP address or DNS of the host. All I have is file://myserver/myapp (4 Replies)
Discussion started by: mohtashims
4 Replies

2. UNIX for Advanced & Expert Users

Best Operating System

Hello All, I want to install Linux on my machine, so please tell me one thing which is the best to install- 1.)Red Hat 2.)Cent OS 3.)Red Hat 4.)Ubuntu 5.)Fedora except that if there is any please tell me. (1 Reply)
Discussion started by: parthmittal2007
1 Replies

3. Homework & Coursework Questions

Operating system LINUX

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a C program that accepts 3 parameters. Each parameter indicates the quantity of product to be produced.... (0 Replies)
Discussion started by: paradise
0 Replies

4. Homework & Coursework Questions

Operating system LINUX

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a C program that accepts 3 parameters. Each parameter indicates the quantity of product to be produced.... (1 Reply)
Discussion started by: paradise
1 Replies

5. Shell Programming and Scripting

Operating system LINUX

Write a C program that accepts 3 parameters. Each parameter indicates the quantity of product to be produced. Each product will be produced in different production line. Ready products will be placed in a buffer area located at the end of each production line. Packaging workers will pack the... (1 Reply)
Discussion started by: paradise
1 Replies

6. Filesystems, Disks and Memory

Fabric Operating System

Would any of your gentlemen have come across a decent reference for the FOS in your wanderings? Brocade just seems to want to sell me classes and FAN books :/ (0 Replies)
Discussion started by: Eronysis
0 Replies

7. UNIX for Dummies Questions & Answers

Unix Operating System?

Hey all, I currently use FreeBSD and linux and have decided I want to use a proper Unix distrobution. Which Unix distro would you members recommend. The only requirments that I have is that I can use some pogramming utilities available. I don't mind the install process. One more thing, I know some... (2 Replies)
Discussion started by: -zorin
2 Replies

8. UNIX for Dummies Questions & Answers

Operating System

Which is much more powerful as an operating system: 1. Windows 2000 2. Windows 98 3. Windows XP 4. Windows ME 5. Unix 6. Linux and why is it much more powerful than the other operating systems that i have mentioned. thanks for your info... (1 Reply)
Discussion started by: alecks1975
1 Replies

9. Filesystems, Disks and Memory

cannot load any operating system

I've tried installing Linux (SuSE because it's the easiest disc I had on hand) and Windows, and neither can boot. The specific problems are below. With Linux: During the installation, I get error message on most of the packages, even though I left all of them up to the default, and it sais... (3 Replies)
Discussion started by: Derrek
3 Replies
Login or Register to Ask a Question