Find the answer to your Linux question:
Results 1 to 5 of 5
new server was built now all scripts that used trap errtrap ERR fail with the following trap: bad signal ERR #!/bin/ksh # Initialize Trap routine. trap errtrap SIGERR # Function ...
  1. #1
    Just Joined!
    Join Date
    May 2007
    Posts
    3

    trap: bad signal ERR

    new server was built now all scripts that used trap errtrap ERR fail with the following

    trap: bad signal ERR
    #!/bin/ksh
    # Initialize Trap routine.
    trap errtrap SIGERR

    # Function for Error Trapping
    function errtrap {
    es=$?
    echo ' ';
    echo "$step_value encountered fatal error! Status : $es";
    echo "************ $progname FAILED! *************";
    echo ' ';
    exit 1;
    }
    echo "hey hey hey hey hey hey"
    exit 0

    gives the following error

    ./STXAC050_BEF[3]: trap: bad signal ERR

    versions
    $ echo $KSH_VERSION
    @(#)PD KSH v5.2.14 99/07/13.2
    (Linux release 2.4.21-47.EL #1 Wed Jul 5 20:46:55 EDT 2006) (0)

    Any ideas why this signal is not available? something we need to set at system level?

    thanks

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    This works for me:
    Code:
    #!/bin/ksh
    
    # @(#) s1       Demonstrate pdksh trap.
    
    echo " pdksh version: $KSH_VERSION"
    
    trap errtrap ERR
    
    errtrap ()
    {
            echo " errtrap executed."
    }
    
    echo
    echo " Begin main."
    
    this-is-a-bad-command
    
    exit 0
    Producing:
    Code:
    % ./s1
     pdksh version: @(#)PD KSH v5.2.14 99/07/13.2
    
     Begin main.
    ./s1[17]: this-is-a-bad-command: not found
     errtrap executed.
    It looks like it is complaining about SIGERR being used in your code rather than ERR. When I used that, I got the error message in your post.

    Your code would be easier to read if you placed it in CODE blocks ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Just Joined!
    Join Date
    May 2007
    Posts
    3
    Sorry I was using ERR, I had just tried SIGERR as I had seen it somewhere in google, I tried the example shell, I get the same message.
    Code:
    /app/stx/shell/>cat bef.ksh
    #!/bin/ksh
    
    # @(#) s1       Demonstrate pdksh trap.
    
    echo " pdksh version: $KSH_VERSION"
    
    trap errtrap ERR
    
    errtrap ()
    {
            echo " errtrap executed."
    }
    
    echo
    echo " Begin main."
    
    this-is-a-bad-command
    
    exit 0
    /app/stx/shell/>chmod 755 bef.ksh
    produces

    Code:
    /app/stx/shell/>bef.ksh
     pdksh version: @(#)PD KSH v5.2.14 99/07/13.2
    ./bef.ksh[7]: trap: bad signal ERR
    /app/stx/shell/>
    any help greatly appreciated.

  4. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    I cannot reproduce your problem.

    I tried the same code, but with bash, and that also worked as expected. I suggest you try that.

    I'll continue to track this thread, but for others to help you, I also suggest that you post some information about your operating system ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  5. #5
    Just Joined!
    Join Date
    May 2007
    Posts
    3
    bash shell seems to work. So I am attempting to use that for now, we will have to take the !/bin/ksh out of all our scripts though. Thanks much

    kernel details
    kernel-2.4.21-47.EL
    kernel-utils-2.4-8.37.15
    kernel-hugemem-2.4.21-47.EL
    kernel-pcmcia-cs-3.1.31-19
    kernel-doc-2.4.21-47.EL
    kernel-smp-2.4.21-47.EL
    kernel-source-2.4.21-47.EL

    shadow-utils-4.0.3-26.RHEL3
    cpio-2.5-4.RHEL3
    logrotate-3.6.9-2.RHEL3
    laus-0.1-70RHEL3
    sendmail-8.12.11-4.RHEL3.6
    openmotif-2.2.3-5.RHEL3.7
    openmotif21-2.1.30-9.RHEL3.8
    redhat-config-services-0.8.5-19.RHEL3.1
    laus-libs-0.1-70RHEL3
    tar-1.13.25-14.RHEL3
    slocate-2.7-3.RHEL3.6
    authd-1.4.1-2.RHEL3
    mysql-3.23.58-16.RHEL3.1
    doxygen-1.3.5-0.RHEL3.1
    chkfontpath-1.9.10-1.RHEL
    libraw1394-0.9.0-10.RHEL3
    xloadimage-4.1-36.RHEL3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...