bash script to read CTRL+D
Hello,
I am trying to make a small script that exits the program when it encouters CTRL+D. I've tried things like Code:
while [[ $in != "^D" ]] Code:
while [[ $in != EOF ]] Code:
while [[ $in != $EOF ]] //this one termitated the program right away |
I am trying to make a small script that exits the program when it encounters CTRL+D
That's logout (signal 1 IIRC) but you can't catch that because it's not a means to end the script. To catch a signal use the Bash "trap" builtin as in "trap 'echo trapped exit, logout or interrupt' 0 1 2". |
Thanks unSpawn, I wasn't aware that this is the way it should be done. I've tried it and it works but not exactly as I want it to. The segment that I'm using is
Code:
trap "echo trapped" 0 1 2 |
Code:
cat | while read line; do ta0kira |
set -o ignoreeof
in your profile |
Thanks for your help everyone. I ended up using unSpawn suggestions and it suits me fine though it is not exactly waht I was looking for.
Regards, V |
All times are GMT -5. The time now is 04:29 PM. |