Linux

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Simple bash problem.

    5 answers - 1561 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Thanks for the quick reply.
    Unfortunately it made no difference putting #!/bin/bash
    This works on every other system I've tried.
    Message
    From: redhat-list-bounces (AT) redhat (DOT) com
    [mailto:redhat-list-bounces (AT) redhat (DOT) com] Behalf Miskell, Craig
    Sent: 29 January 2007 00:07
    To: General Red Hat Linux discussion list
    Subject: RE: Simple bash problem.
    Anyone know why the following simple bash script fails
    on RHEL3 (fully patched)? It seems the "trap" command
    is being silently ignored.
    --
    #!/bin/sh
    sigtrap () {
    echo "Caught signal!"
    exit 0
    }
    trap sigtrap 1 2 3 15
    while read X; do
    echo $X
    done
    I'm not 100% sure, but I think it might be because of the #! Line. Bash
    might be seeing that you've invoked with "/bin/sh", and is deciding to
    operate in limited PSIX shell mode (sorry, the exact terminology for
    that escapes me). Try #!/bin/bash and see how that goes,
    Craig
    Attention: The information contained in this message and/or attachments
    from AgResearch Limited is intended only for the persons or entities
    to which it is addressed and may contain confidential and/or privileged
    material. Any review, retransmission, dissemination or other use of, or
    taking of any action in reliance upon, this information by persons or
    entities other than the intended recipients is prohibited by AgResearch
    Limited. If you have received this message in error, please notify the
    sender immediately.
  • No.1 | | 469 bytes | |

    1/28/07, Simon Ashford <Simon.Ashford (AT) npl (DOT) co.ukwrote:

    Thanks for the quick reply.

    Unfortunately it made no difference putting #!/bin/bash

    This works on every other system I've tried.

    I just tested on RHEL3 and RHEL4 here. Worked as I guess you would
    expect on RHEL4 but on RHEL3 the SIGQUIT was ignored. Looking in the
    manpage I'm not sure I understand why it isn't being ignored in
    RHEL4?!

    John
  • No.2 | | 652 bytes | |

    1/28/07, inode0 <inode0 (AT) gmail (DOT) comwrote:
    1/28/07, Simon Ashford <Simon.Ashford (AT) npl (DOT) co.ukwrote:

    Thanks for the quick reply.

    Unfortunately it made no difference putting #!/bin/bash

    This works on every other system I've tried.

    I just tested on RHEL3 and RHEL4 here. Worked as I guess you would
    expect on RHEL4 but on RHEL3 the SIGQUIT was ignored. Looking in the
    manpage I'm not sure I understand why it isn't being ignored in
    RHEL4?!

    Adding a "trap -p" to the script shows that none of the signals are
    being trapped on RHEL3 by this script. Curious.

    John
  • No.3 | | 817 bytes | |

    1/28/07, inode0 <inode0 (AT) gmail (DOT) comwrote:
    1/28/07, inode0 <inode0 (AT) gmail (DOT) comwrote:
    1/28/07, Simon Ashford <Simon.Ashford (AT) npl (DOT) co.ukwrote:

    Thanks for the quick reply.

    Unfortunately it made no difference putting #!/bin/bash

    This works on every other system I've tried.

    I just tested on RHEL3 and RHEL4 here. Worked as I guess you would
    expect on RHEL4 but on RHEL3 the SIGQUIT was ignored. Looking in the
    manpage I'm not sure I understand why it isn't being ignored in
    RHEL4?!

    Adding a "trap -p" to the script shows that none of the signals are
    being trapped on RHEL3 by this script. Curious.

    trap "sigtrap " 1 2 3 15

    seems to get it to work on RHEL3 but this seems pretty buggy to me.

    John
  • No.4 | | 1208 bytes | |

    1/28/07, inode0 <inode0 (AT) gmail (DOT) comwrote:
    1/28/07, inode0 <inode0 (AT) gmail (DOT) comwrote:
    1/28/07, inode0 <inode0 (AT) gmail (DOT) comwrote:
    1/28/07, Simon Ashford <Simon.Ashford (AT) npl (DOT) co.ukwrote:

    Thanks for the quick reply.

    Unfortunately it made no difference putting #!/bin/bash

    This works on every other system I've tried.

    I just tested on RHEL3 and RHEL4 here. Worked as I guess you would
    expect on RHEL4 but on RHEL3 the SIGQUIT was ignored. Looking in the
    manpage I'm not sure I understand why it isn't being ignored in
    RHEL4?!

    Adding a "trap -p" to the script shows that none of the signals are
    being trapped on RHEL3 by this script. Curious.

    trap "sigtrap " 1 2 3 15

    seems to get it to work on RHEL3 but this seems pretty buggy to me.

    , this is really my last followup to myself. Giving this a little
    more thought leads me to observe that sigtrap is being caught as part
    of your sigspec changing the name of your function to something
    that isn't legal in the sigspec would probably be a good idea in any
    event and then RHEL3 works as you expect.

    John
  • No.5 | | 485 bytes | |

    inode0 wrote:

    , this is really my last followup to myself. Giving this a little
    more thought leads me to observe that sigtrap is being caught as part
    of your sigspec changing the name of your function to something
    that isn't legal in the sigspec would probably be a good idea in any
    event and then RHEL3 works as you expect.

    Reminds me of when I wrote a test shell script called "test" and
    couldn't for the life of me get it to work correctly. :)

Re: Simple bash problem.


max 4000 letters.
Your nickname that display:
In order to stop the spam: 5 + 4 =
QUESTION ON "Linux"

EMSDN.COM