[oracle@server1 scripts]$ ./test_db.ksh -b 4096
-b is for Non-default Block Size
BLOCK_SIZE=4096
[oracle@server1 scripts]$ ./test_db.ksh -c AL32UTF8
-c is for non-default character set
CHARACTER_SET=AL32UTF8
Here is my Complete Script:
Code:
#!/bin/ksh
bflg=0
cflg=0
dflg=0
while getopts "b(blk):c(char):d(default):h(help)" opt
do case $opt in
(b) bflg=1;;
(c) cflg=1;;
(d) dflg=1;;
(h) echo "Sample Script"
exit 0;;
(?) echo "Not valid option"
exit 1;;
esac
done
shift $((OPTIND - 1))
# Verify that at least one option was given and that two operands are present...
if [ $((bflg + cflg + dflg)) -eq 0 ]
then
echo "Atleast One option required"
exit 3
fi
# Perform the requested actions...
if [ $bflg -eq 1 ]
then
if [ $# -ne 1 ]
then
echo "arguments allowed: 1"
exit 2
else
BLK_SIZE=$1
echo "-b is for Non-default Block Size"
echo "BLOCK_SIZE=$BLK_SIZE"
fi
fi
if [ $cflg -eq 1 ]
then
if [ $# -ne 1 ]
then
echo "arguments allowed: 1"
exit 2
else
CHAR_SET=$1
echo "-c is for non-default character set"
echo "CHARACTER_SET=$CHAR_SET"
fi
fi
if [ $dflg -eq 1 ]
then
if [ $# -ne 3 ]
then
echo "arguments allowed: 3"
exit 2
else
ORACLE_SID=$1
ORACLE_VER=$2
ENV_TYPE=$3
echo "-d is Default option"
echo "ORACLE_SID=$ORACLE_SID"
echo "ORACLE_VERSION=$ORACLE_VER"
echo "ENV_TYPE=$ENV_TYPE"
fi
fi
I want this script to work when i use -b or -c or both(-b &-c) along with -d option.
Can you guys please guide me in achieving this.
Please let me know if you need more information.
Last edited by veeresh_15; 12-08-2014 at 12:01 PM..
Here is my post with a question about getopts. I am running korn shell on Solaris 5.8. I am trying to ensure that certain options require a parameter, which is easy enough. I have found that if multiple options are entered on the command line together, but the parameter for one of the options is... (1 Reply)
I need to create a shell script having the menu with few options such as
1. Listing 2. Change permissions 3. Modify Contents 4. Delete Files 5. Exit
1. For 1. Listing: Display a special listing of files showing their date of modification and access time (side by side) along with their... (2 Replies)
I've created a wxpython gui for the shred command. I can successfully mix and match all the shred options except two: -size and --random-source. (Man page definitions below). -size and --random-source seem to only work when they are used as the sole option passed.
For example,
I can zero a... (0 Replies)
Hi,
Basically I've written a game in ncurses that supports multiple players. Each player has a process associated with him which shares a segment of memory in which the player's structures are stored, and these structured are accessed by the 'server' program and handled there. The scope of the... (13 Replies)
Hi i have written a shell script that takes only single ip address from the user and calculates its latency and reliability, can you please tell me that what should be done if i want that user should enter 100 or 1000 ip address (5 Replies)
Hi I'm looking to take a user input and use it to effect just two characters in a command rather than having multiple functions for each one.
function baseencode() {
echo "This function handles the following: $YELLOW base64 base32 base16 $NORMAL"
echo "$GREEN Select 64 32 or 16 $NORMAL"... (2 Replies)
Dear all,
My work is completely stuck cos of the following issue. Please find it here and kindly help me.
Task is following:
I have set of files with such pattern
1t-rw-rw-r-- 1 emily emily 119 Jun 11 10:45 vgtree_5_1_pfs.root
3t-rw-rw-r-- 1 emily emily 145 Jun 11 10:46 vgtree_5_3_pfs.root... (4 Replies)
Hi,
I am trying to SFTP files in a script that i created.
But the problem is i have to use -oPort and -b together. how can i get this done.
I have tried as below command in my script but with no luck
sftp -oPort=102 -b <batchfilename> username@server
sftp -oPort=102 -ob... (1 Reply)