Sponsored Content
Top Forums Shell Programming and Scripting Query regarding portable script Post 302218712 by dhiraj4mann on Saturday 26th of July 2008 05:17:52 AM
Old 07-26-2008
Query regarding portable script

Dear Experts,

I want to write a script which has to work on Solaris & Linux sytems.
The problem which i am facing is, there are commands whose options are different on both OS's. For example ping.

On Solaris i have to write:
ping $host 1
to check if the host is alive

On Linux i have to use following command
ping $host -c 1
One way to write generic script is
if [ `uname -s` == "SunOS" ]
then
OPT="1"
fi
if [ `uname -s` == "Linux" ]
then
OPT="-c 1"
fi

ping $host $OPT
The only problem with this approach is that for every set of options i have make OS specific check. Is there some better way of achieving same in shell scripts. In make i know sth like following works:

OPT.solaris="1"
OPT.linux="-c 1"
OPT=$(OPT.$(OSTYPE))

Is something like this possible in shell scripts also?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script query

Hi, I am stuck assigning a value to a variable. I am trying to assign a value to a variable but getting error.... IP_ADDR=grep 'I.P. Address' /install/cfgdist/`uname -n`.cfg | cut -d : -f 2| cut -d . -f 1-3| sed s/" "//g I am using this script to grep first three octets of an IP address... (4 Replies)
Discussion started by: max29583
4 Replies

2. UNIX for Dummies Questions & Answers

Expect Script - if/else query

Hi, I am trying to write an expect script that contains an if/else statement based on a result ... but I'm having a bit of trouble. The code below shows my script - it all works fine but when I include the second expect function it ignores it and moves on ... can anyone help with this ...... (1 Reply)
Discussion started by: spikey
1 Replies

3. Shell Programming and Scripting

shell script query

hi all i have a shell script for connecting in sybase env what i need is i have around 10 servers , i need to connect to all servers and retrive the database inforamtion in the servers and display them any one of u have it request to share it asap ! "QUERY TO Connect to all servers... (1 Reply)
Discussion started by: mvsramarao
1 Replies

4. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

5. Shell Programming and Scripting

Script query

Hi Admins, count=`ps -ef | grep LIST_8i | grep -v grep|wc -l` pid=`ps -ef|grep LIST_8i|grep -v grep|awk '{print $2}'` if then lsnrctl stop LIST_8i >> ${log} sleep 5 lsnrctl start LIST_8i >> ${log} else echo " " lsnrctl start LIST_8i >> ${log} fi 2>&1 The script restarts... (5 Replies)
Discussion started by: newaix
5 Replies

6. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

7. Shell Programming and Scripting

Portable Shell Script - Determine Which Version of Binary is Installed?

I currently have a shell script that utilizes the "Date" binary - this application is slightly different on OS X (BSD General Commmand) and Linux systems (gnu date). In particular, the version on OS X requires the following to get a date 14 days in the future "date -v+14d -u +%Y-%m-%d" where gnu... (1 Reply)
Discussion started by: colinjohnson
1 Replies

8. Shell Programming and Scripting

Argument to the script query

Hi, I have a script invest.sh which takes two inputs i.e the name of the properties file and the file permissions for eg: ./invest.sh app12.properties 664Now i wish to give a folder path /opt/app/properties instead of the properties file and the invest.sh script should lookout for all the... (3 Replies)
Discussion started by: mohtashims
3 Replies

9. Shell Programming and Scripting

Portable shell script advise

All, I have a need for a portable shell script for LInux and HPUX. The script has a simple need; Check for local files of a specific name (i.e. filename*), scp them to another system, and archive them to a folder. The script runs via cron. I first wrote the script in Linux (bash with gnu... (4 Replies)
Discussion started by: hburnswell
4 Replies

10. Shell Programming and Scripting

Tip: template for a safe and portable script

In an attempt to finally end this article I start this new thread. Here is a template for a safe and portable script. #!/bin/bash # /bin/bash exists on most still supported Unixes # # tr and date behave better with if ; then export LC_ALL=C; else export LANG=C; fi # # Unix optional packages... (2 Replies)
Discussion started by: MadeInGermany
2 Replies
SIEVESHELL(1)						User Contributed Perl Documentation					     SIEVESHELL(1)

NAME
sieveshell - remotely manipulate sieve scripts SYNOPSIS
sieveshell [--user=user] [--authname=authname] [--realm=realm] [--exec=script] server[:port] sieveshell --help DESCRIPTION
sieveshell allows users to manipulate their scripts on a remote server. It works via MANAGESIEVE, a work in progress. The following commands are recognized: list list scripts on server. put <filename> upload script to server. get <name> [<filename>] get script. if no filename display to stdout delete <name> delete script. activate <name> activate script. deactivate deactivate all scripts. OPTIONS
-u user, --user=user The authorization name to request; by default, derived from the authentication credentials. -a authname, --authname=authname The user to use for authentication (defaults to current user). -r realm, --realm=realm The realm to attempt authentication in. -e script, --exec=script Instead of working interactively, run commands from script, and exit when done. REFERENCES
[MANAGESIEVE] Martin, T.; "A Protocol for Remotely Managing Sieve Scripts", draft-ietf-managesieve-03.txt, Mirapoint, Inc.; May 2001, work in progress. AUTHOR
Tim Martin <tmartin@mirapoint.com>, and the rest of the Cyrus team <cyrus-bugs@andrew.cmu.edu>. perl v5.10.0 2008-04-04 SIEVESHELL(1)
All times are GMT -4. The time now is 07:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy