can any one explain the meaning of the below code ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting can any one explain the meaning of the below code ?
# 1  
Old 04-02-2009
can any one explain the meaning of the below code ?

Code:
while getopts :g:l:h: KEY $*
do
   case $KEY
   in
       g) NAME=$OPTARG ;;
       l) LAB=$OPTARG ;;
       h) HD=$OPTARG ;;
       *) echo "Illegal option: $OPTARG"
          echo "$usage"
          exitStatus=1
          exitGrace
   esac
done


Last edited by jim mcnamara; 04-02-2009 at 11:16 AM.. Reason: PLEASE use code tags. Thanks
# 2  
Old 04-02-2009
Hello there,

Your script accepts three command line options -l -h and -g and each of these options requires an argument. The case inside checks the validity of the inserted values. You will run something like this

Code:
./yourscript -g <NAME> -l <LAB> -h <HD>


Regards
Smilie
# 3  
Old 04-03-2009
thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What is the meaning of the following Perl Code?

Hi All Can any one please help me to understand the below Perl Code package Win32::File; # # File.pm # Written by Douglas_Lankshear@ActiveWare.com # # subsequent hacks: # Gurusamy Sarathy # $VERSION = '0.06'; require Exporter; require DynaLoader; @ISA= qw( Exporter... (1 Reply)
Discussion started by: adisky123
1 Replies

2. Shell Programming and Scripting

can you explain this sed code?

can anyone please explain this code? sed ':a;N;$!ba;s/]\n//g' file it replaces lines ending with "]" and concatenates with the next line so that line1] line2 becomes line1line2 i don't understand this part: :a;N;$!ba; I have noted that I can replace "a" with any letter: ... (1 Reply)
Discussion started by: locoroco
1 Replies

3. Shell Programming and Scripting

Please explain what this code is doing

Hi, Pls explain me what the below code is doing. specially meaning if -a while calling test function- case $1 in 1) beg_dt=01; end_dt=07 ;; 2) beg_dt=08; end_dt=14 ;; 3) beg_dt=15; end_dt=21 ;; 4) beg_dt=22; end_dt=28 ;; 5) beg_dt=29; end_dt=31 ;; esac test \( `date +%w` -eq $2 -a... (3 Replies)
Discussion started by: sendtoshailesh
3 Replies

4. Shell Programming and Scripting

Explain SED code

Hi, Can anyone pls explain me the below SED code in detail. sed -e :a -e '$!N;s/\n//;ta' -e P -e D When this code is executed with a file(has 1lac records), it is taking very long time to process. So I wanted to modify this SED code with equivalant AWK code. Thanks, Sri (1 Reply)
Discussion started by: srilaxmi
1 Replies

5. Programming

Explain a block of code:

Hi, I have this block in a code and I need to know it's meaning: bool selectEvents = config.get("selectEvents",false); if (selectEvents) { ifstream in("events"); while (in) { int run, evt; in >> run >> evt; if (in.eof()) break; ... (5 Replies)
Discussion started by: eager2no
5 Replies

6. Shell Programming and Scripting

Can any one explain what this code will do

ccc_con,CCC_CON,0 Above is the input for this code #!/usr/bin/bash my_path=`dirname $0` T_table=$1 S_table=$2 P_table=$3 #Star new code while read ${my_path}/arch_table_list.txt { awk -F "," '{print $1}' ${my_path}/arch_table_list.txt ${S_table} awk -F "," '{print... (1 Reply)
Discussion started by: scorp_rahul23
1 Replies

7. UNIX for Advanced & Expert Users

explain the code

Hi , Can anyone explains what does the below highlighted statements means: # Set environment variables . ${0%/*}/wrkenv.sh jobName_sh=${0##*/} jobName=${jobName_sh%.*} Thanks, Sri (1 Reply)
Discussion started by: srilaxmi
1 Replies

8. Shell Programming and Scripting

Meaning of code

Hi Can anybody tell me what is the meaning of the following code? i=4 j=1 k=0 Specialy meaning of this line echo $? Specialy meaning of this line echo $? Specialy meaning of this line echo $? Thanks in advance Sas (3 Replies)
Discussion started by: SasDutta
3 Replies

9. Shell Programming and Scripting

Whats the meaning of this code

Hi all, I am unable interpret this code ......... nohup $OPSSHLPATH/mkt_sas_load_cic.sh $db_name $process_id $loc_mm > $OPSLSTPATH/mkt_sas_load_cic.out & Thanks ....In advance (7 Replies)
Discussion started by: dhananjaysk
7 Replies

10. UNIX for Dummies Questions & Answers

could someone explain this code

hey peeps could someone explain what this part of the code means: 'if echo $* | grep -q' $i '|| thanks tHe_nEw_GuY (2 Replies)
Discussion started by: the_new_guy
2 Replies
Login or Register to Ask a Question