Sponsored Content
Top Forums Shell Programming and Scripting Problem in understanding debugging Post 302769038 by scriptor on Monday 11th of February 2013 05:35:14 AM
Old 02-11-2013
Problem in understanding debugging

Hi

i was going through the script debugging technique. below example was given in the book.
Code:
1   #!/bin/sh
     2
     3   Failed() {
     4   if [ $1 -ne 0 ] ; then
     5   echo "Failed. Exiting." ; exit 1 ;
     6   fi
     7   echo "Done."
     8   }
     9
    10   echo "Deleting old backups, please wait... \c"
    11   rm -r backup > /dev/null 2>&1
    12   Failed $?
    13
    14   echo "Make backup (y/n)? \c"
    15   read RESPONSE
    16   case $RESPONSE in
    17   [yY]|[Yy][Ee][Ss]|*)
    18   echo "Making backup, please wait... \c"
    19   cp -r docs backup
    20   Failed
    21   [nN]|[Nn][Oo])
    22   echo "Backup Skipped." ;;
    23  esac

my problem is when author debug the script with -nv option he is getting below o/p
Code:
[nN]|[Nn][Oo]) ./buggy2.sh: syntax error at line 21: ')'
unexpected

however when i debug the same script with same option i am getting below o/p
Code:
./debug6: 21: Syntax error: ")" unexpected (expecting ";;")

in my case i just change the name of the script.(i use debug6 and author used buggy2.sh rest i simply copy paste the script.)
why here i am getting bit more info in compare to author's o/p. is there is some problem or it is ok.

to correct the script author suggested to put (; ; after Failed in line no. 20 like below.
Code:
Failed ;;

my question is why i need to use 2 colon after Failed not one?
also how does author know just by seeing one single line(means by seeing o/p of debug) that he need to put 2 colon after Failed.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

egrep understanding problem

Hi, Can anyone please let me know the meaning of this line,i am not able to understand the egrep part(egrep '^{1,2}).This will search for this combination in beginning but what does the values in {}signifies here. /bin/echo $WhenToRun | egrep '^{1,2}:$' >/dev/null (1 Reply)
Discussion started by: namishtiwari
1 Replies

2. Solaris

debugging problem

OS : SOLARIS 10 debug tool :$gdb -v GNU gdb 6.6 compiler : $gcc -v gcc version 2.95.3 20010315 (release) When i tried to debug my application i got the following error. $gdb Pal GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. This GDB was... (2 Replies)
Discussion started by: satish@123
2 Replies

3. Shell Programming and Scripting

Problem with the shell script for understanding

Can Anybody please tell me the meaning of the script: #!/bin/sh str=$@ echo $str | sed 's/.*\\//' exit 0 (6 Replies)
Discussion started by: nixhead
6 Replies

4. UNIX for Dummies Questions & Answers

Problem understanding Paths

If I don't explain my issue well enough, I apologize ahead of time, extreme newbie here to scripting. I'm currently learning scripting from books and have moved on to the text Wicked Cool Shell Scripts by Dave Taylor, but there are still basic concepts that I'm having trouble understanding. ... (10 Replies)
Discussion started by: Chasman78
10 Replies

5. Shell Programming and Scripting

Problem in understanding export uses

i am beginner in shell scripting. not able to understand what below line will do. PS1=${HOST:=Žuname -nŽ}"$ " ; export PS1 HOST below is the script #!/bin/hash PS1=${HOST:=Žuname -nŽ}"$ " ; export PS1 HOST ; echo $PS1 and i getting the below output Žuname -nŽ$ (25 Replies)
Discussion started by: scriptor
25 Replies

6. UNIX for Dummies Questions & Answers

GDB Debugging Problem

I have added some code in my file. I have created executable rpm file of our code and also I have created debuginfo and debugsource files and installed all three. But when I debug in gdb I see the the code changes in soucre file. But the break point does not hit at that place as if it did not... (1 Reply)
Discussion started by: rupeshkp728
1 Replies

7. Shell Programming and Scripting

Debugging mysterious perl script problem

the attached perl script is a deamon that, once kicked off from the command line, it runs in the background and waits for the master server to tell it what plugins to run. the script works well. but the problem is, whenever i start it, after about a few seconds of starting it, i start getting... (4 Replies)
Discussion started by: SkySmart
4 Replies

8. Programming

Best reference for understanding core file and debugging for different architectures

Hi , could someone suggest best reference for core file understanding , analysis , debugging for different architectures like what registers represent what in a architecture specific core .. how to get maximum information out of corrupted core different tools and how they work and how to... (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies

9. Shell Programming and Scripting

Problem with (Understanding) function

I have this code #!/bin/bash LZ () { RETVAL="\n$(date +%Y-%m-%d_%H-%M-%S) --- " return RETVAL } echo -e $LZ"Test" sleep 3 echo -e $LZ"Test" which I want to use to make logentrys on my NAS. I expect of this code that there would be output like 2017-03-07_11-00-00 --- Test (4 Replies)
Discussion started by: matrois
4 Replies
Credential Constants(3) 				       globus gsi credential					   Credential Constants(3)

NAME
Credential Constants - Enumerations enum globus_gsi_cred_error_t { GLOBUS_GSI_CRED_ERROR_SUCCESS = 0, GLOBUS_GSI_CRED_ERROR_READING_PROXY_CRED = 1, GLOBUS_GSI_CRED_ERROR_READING_HOST_CRED = 2, GLOBUS_GSI_CRED_ERROR_READING_SERVICE_CRED = 3, GLOBUS_GSI_CRED_ERROR_READING_CRED = 4, GLOBUS_GSI_CRED_ERROR_WRITING_CRED = 5, GLOBUS_GSI_CRED_ERROR_WRITING_PROXY_CRED = 6, GLOBUS_GSI_CRED_ERROR_CHECKING_PROXY = 7, GLOBUS_GSI_CRED_ERROR_VERIFYING_CRED = 8, GLOBUS_GSI_CRED_ERROR_WITH_CRED = 9, GLOBUS_GSI_CRED_ERROR_WITH_CRED_CERT = 10, GLOBUS_GSI_CRED_ERROR_WITH_CRED_PRIVATE_KEY = 11, GLOBUS_GSI_CRED_ERROR_WITH_CRED_CERT_CHAIN = 12, GLOBUS_GSI_CRED_ERROR_ERRNO = 13, GLOBUS_GSI_CRED_ERROR_SYSTEM_CONFIG = 14, GLOBUS_GSI_CRED_ERROR_WITH_CRED_HANDLE_ATTRS = 15, GLOBUS_GSI_CRED_ERROR_WITH_SSL_CTX = 16, GLOBUS_GSI_CRED_ERROR_WITH_CALLBACK_DATA = 17, GLOBUS_GSI_CRED_ERROR_CREATING_ERROR_OBJ = 18, GLOBUS_GSI_CRED_ERROR_KEY_IS_PASS_PROTECTED = 19, GLOBUS_GSI_CRED_ERROR_NO_CRED_FOUND = 20, GLOBUS_GSI_CRED_ERROR_SUBJECT_CMP = 21, GLOBUS_GSI_CRED_ERROR_GETTING_SERVICE_NAME = 22, GLOBUS_GSI_CRED_ERROR_BAD_PARAMETER = 23, GLOBUS_GSI_CRED_ERROR_WITH_CRED_CERT_NAME = 24, GLOBUS_GSI_CRED_ERROR_LAST = 25 } enum globus_gsi_cred_type_t Enumeration Type Documentation enum globus_gsi_cred_error_t Credential Error codes. Enumerator: GLOBUS_GSI_CRED_ERROR_SUCCESS Success - never used. GLOBUS_GSI_CRED_ERROR_READING_PROXY_CRED Failed to read proxy credential. GLOBUS_GSI_CRED_ERROR_READING_HOST_CRED Failed to read host credential. GLOBUS_GSI_CRED_ERROR_READING_SERVICE_CRED Failed to read service credential. GLOBUS_GSI_CRED_ERROR_READING_CRED Failed to read user credential. GLOBUS_GSI_CRED_ERROR_WRITING_CRED Failed to write credential. GLOBUS_GSI_CRED_ERROR_WRITING_PROXY_CRED Failed to write proxy credential. GLOBUS_GSI_CRED_ERROR_CHECKING_PROXY Error checking for proxy credential. GLOBUS_GSI_CRED_ERROR_VERIFYING_CRED Failed to verify credential. GLOBUS_GSI_CRED_ERROR_WITH_CRED Invalid credential. GLOBUS_GSI_CRED_ERROR_WITH_CRED_CERT Invalid certificate. GLOBUS_GSI_CRED_ERROR_WITH_CRED_PRIVATE_KEY Invalid private key. GLOBUS_GSI_CRED_ERROR_WITH_CRED_CERT_CHAIN Invalid certificate chain. GLOBUS_GSI_CRED_ERROR_ERRNO System error. GLOBUS_GSI_CRED_ERROR_SYSTEM_CONFIG A Globus GSI System Configuration call failed. GLOBUS_GSI_CRED_ERROR_WITH_CRED_HANDLE_ATTRS Invalid credential handle attributes. GLOBUS_GSI_CRED_ERROR_WITH_SSL_CTX Faulty SSL context. GLOBUS_GSI_CRED_ERROR_WITH_CALLBACK_DATA Faulty callback data. GLOBUS_GSI_CRED_ERROR_CREATING_ERROR_OBJ Failed to aggregate errors. GLOBUS_GSI_CRED_ERROR_KEY_IS_PASS_PROTECTED Error reading private key - the key is password protected. GLOBUS_GSI_CRED_ERROR_NO_CRED_FOUND Couldn't find credential to read. GLOBUS_GSI_CRED_ERROR_SUBJECT_CMP Credential subjects do not compare. GLOBUS_GSI_CRED_ERROR_GETTING_SERVICE_NAME Unable to obtain service name from CN entry. GLOBUS_GSI_CRED_ERROR_BAD_PARAMETER Invalid function parameter. GLOBUS_GSI_CRED_ERROR_WITH_CRED_CERT_NAME Failed to process certificate subject. GLOBUS_GSI_CRED_ERROR_LAST End marker - never used. enum globus_gsi_cred_type_t Credential Type An enum representing a GSI Credential Type which holds info about the type of a particular credential. The three types of credential can be: GLOBUS_PROXY, GLOBUS_USER, or GLOBUS_HOST. See also: Credential Handle Management Author Generated automatically by Doxygen for globus gsi credential from the source code. Version 5.3 Mon Apr 30 2012 Credential Constants(3)
All times are GMT -4. The time now is 08:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy