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 POSIX 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.
=======================================================================

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list



Relevant Pages

  • Re: Newbie Three
    ... echo "tesgform"; ... echo "suspected alien invasion case topic table"; ... echo "suspected alien invasion unknown group name"; ...
    (comp.lang.php)
  • Newbie Three
    ... echo "tesgform"; ... echo "suspected alien invasion case topic table"; ... echo "suspected alien invasion unknown group name"; ...
    (comp.lang.php)
  • Re: Apple Remote Desktop root vulneravility
    ... If you are trying to run a remote install script such as the Adobe Silent installer, use the lock screen feature in ARD. ... # umount any previous mounted installer images ... trap 'cd "$"' EXIT ... echo "This version of MacOS is not supported." ...
    (Bugtraq)
  • Re: Shell Script to Remove Old Files
    ... Note it needs a TSM server: ... # Verify command line arguments ... echo "\nError: $STARTDIR does not exist.\n" ...
    (comp.unix.admin)
  • Re: dummy update
    ... ## Script to find INPLACE ALTERS in a table/database without locking up ... echo "Failed to get DATA PAGES from oncheck output ..please check ... sql_stmt=`echo "UNLOAD TO tab.out \ ...
    (comp.databases.informix)