One Script on all the Unix flavors


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting One Script on all the Unix flavors
# 1  
Old 06-05-2009
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
# 2  
Old 06-05-2009
use the command "uname -s" before performing "if" condition

-- Jayan Jayaseelan
# 3  
Old 06-05-2009
[ X`uname` = XFreeBSD ] && echo 1 || echo 2;
# 4  
Old 06-05-2009
Hi mirusnet,

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

Thanks for your suggestion

Praveen
# 5  
Old 06-05-2009
Command uname will be quite useful for you.
# 6  
Old 06-05-2009
Quote:
Originally Posted by tcsprak
Is it possible to have a single script that runs on all the platforms?

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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Downloading hdfs file to local UNIX through UNIX script

Hi All , I am very new to unix script.I am aware of unix commands but never put together in unix script level.If any one can suggest me technical guidance in the below scenario that will highly beneficial. Data have been already migrated from mainframe to Hadoop file system(HDFS).HDFS server... (15 Replies)
Discussion started by: STCET22
15 Replies

2. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

3. Shell Programming and Scripting

Time zone issues in UNIX flavors

Hello All, I am in process of migrating all my scripts from AIX box to Linux box. In one of my script I calculate my last week date with the below command $ TZ=EDT+172 date +%F 2012-12-13 $ uname -a AIX 1 7 000B29AAD400 Now when I tried running the same in Linux, it gives a false... (2 Replies)
Discussion started by: sathyaonnuix
2 Replies

4. UNIX for Dummies Questions & Answers

Unix flavors that run on x86, x86_64 bit processors?

Hello everyone. This is an awesome forum. Glad to have joined! :) I use Linux mostly, even for Desktop usage. I just love everything about it, all the way down to how the font looks while browsing. Its just so sleek and sexy. But I also boot Windows for those programs I just need that only... (23 Replies)
Discussion started by: insomnia
23 Replies

5. Shell Programming and Scripting

FTP from windows to unix server using unix shell script

Hi, Is it possible to ftp a huge zip file from windows to unix server using unix shell scripting? If so what command i need to use. thanks in advance. (1 Reply)
Discussion started by: Shri123
1 Replies

6. Shell Programming and Scripting

Get all types of shell supported on any unix flavors.

Hello - Is there a command/way we can find out, what shells are supported on a Unix machine? Please let me know. Thanks, Manju (3 Replies)
Discussion started by: manju--
3 Replies

7. Shell Programming and Scripting

FTP script for sending a file from one unix directory to another unix server director

Hi, My local server is :/usr/abcd/ Remote server is :/Usr/host/test/ I want to send files from local unix directory(All files starting with O_999) to remote host unix directory. Can any body give me the Unix Shell script to do this. One more doubt: Shall we need to change the file... (1 Reply)
Discussion started by: raja_1234
1 Replies

8. UNIX for Dummies Questions & Answers

What exactly is a Unix Flavors means??

could anybody tell me what is a unix flavor? (4 Replies)
Discussion started by: human
4 Replies

9. What is on Your Mind?

Different flavors of Linux

What are the different flavors of Linux? (1 Reply)
Discussion started by: SubbaraoV
1 Replies

10. UNIX Desktop Questions & Answers

UNIX flavors

Are there any flavors of UNIX which are better suited for implementation in the field of 3d animation, if so what are they? (3 Replies)
Discussion started by: aloysius1001
3 Replies
Login or Register to Ask a Question