VM trap may work differently than a pure install trap.
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
That is the last reply I received from my instructor, and I'm looking for some alternatives.
When using the trap command, the echo statement does not return to the console. Instead, there are the spaces, which indicates to me that the echo command is recognized but the termial won't display the characters. This is based on 3 weeks of experience.
I've tried this same script in Knoppix and Ubuntu, both of which are clean installed, and the Toolwire virtual environment that the college provides and cannot get this script to echo as such:
This is a last ditched effort to solve the problem, the instructor and I have been going at this for a couple of days and it's really time to move on. I still want to solve this so I am reaching out to all of you to see if I can get an understanding of the dynamic happening here. Mostly becuase the book says the script works, it works for the instructor and a classmate, just not me.
I hope I have provided enough information. Let me know if I need to post something else such as a screenshot.
3. The attempts at a solution (include all code and scripts):
Script
Output
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University Of Phoenix - Online; Dr. Lori Nicholson; POS 421
Instructor Feedback:
I don't think it has anything to do with you and your code - after I made a few corrections to your script - but I think it may be your system setup.
The trap is captured - that's not the issue. The issue is what happens after the program execution is stopped by the trap. The system will not let it continue one more step and echo out the display to the screen. The trap stops the program but doesn't continue to execute the shell script to the point where we see the text and the echo command is executed.
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
I pasted the quoted code into a file and ran it and - to my surprise - it worked. I would have expected this:
to caue problems, it "just doesn't seem right", but then, i use Korn Shell most of the times and avoid bash like the plague. I would have written:
which should do the same and is POSIXly correct (notice the spaces around "((" and "))", they are necessary), but: never argue with success, yours obviously works.
One thing i noticed, though, was: as soon as i pressed "CTRL-C" the trap was executed but the "sleep 10" was interrupted and then skipped. Pressing CTRL-C often enough let me get through with the script in less than half a minute, whereas 10x 10 seconds of sleeping should have taken 1min 40sec (plus some for the rest).
So, probably there is something with your setup. I have no idea what that would be, though. I tried in an XTerm on Fedora without any real changes and it worked as expected.
I pasted the quoted code into a file and ran it and - to my surprise - it worked. I would have expected this:
to caue problems, it "just doesn't seem right", but then, i use Korn Shell most of the times and avoid bash like the plague. I would have written:
which should do the same and is POSIXly correct (notice the spaces around "((" and "))", they are necessary), but: never argue with success, yours obviously works.
One thing i noticed, though, was: as soon as i pressed "CTRL-C" the trap was executed but the "sleep 10" was interrupted and then skipped. Pressing CTRL-C often enough let me get through with the script in less than half a minute, whereas 10x 10 seconds of sleeping should have taken 1min 40sec (plus some for the rest).
So, probably there is something with your setup. I have no idea what that would be, though. I tried in an XTerm on Fedora without any real changes and it worked as expected.
I hope this helps.
bakunin
I just wanted to acknowledge your post bakunin. I'm not at a machine now but I'd like to not that when you say, 'sleep 10 was interrupted', that makes sense.
i am familiar with the += accumulator from Java, and haven't tried this syntax yet. So I consider this a step in the positive direction. In addition, I haven't tried XTerm yet either. I have my fingers crossed that this will make a difference. I'm really a hardware guy and in my experience, this is is a display issue. I think that my instructor, you, and myself agree that this has something to do with the way I'm setup, and a possibility of doing this in a virtual environment.
I thought I was doing myself a favor by running VirtualBox so that I could have a couple of Linux distributions and Windows Server 2008 r2 running all under the same umbrella. I haven't tried an actual install yet becuase I just didn't have time, and that's really the next step, besides trying to talk it out here.
First time trying to work with signals in Perl.
Reviewing example I try it, but not able to get it work for 'exit'.
I hope, I am correct, assuming, that the ending any code by
exit $return_code;
the $SIG{EXIT} should be de-referenced and processed?!
So, I have such code, that, I assume,... (5 Replies)
Hi
At the beginning of my script, i will create a file and at the end of the script i will delete that.
But i got to delete the file even if the process is forcefully killed, or server is rebooted...
I think i can make use of trap signal, but couldnt figure out how and where to use in my... (4 Replies)
Hi folks,
I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:....
The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
I have a script
#!/bin/ksh
trap cleanup 20
cleanup()
{
cat $t.log
echo Caught
exit 1
}
if ;then
echo Found >>t.log
exit 20
else
echo Not found >>t.log
exit 20
fi (5 Replies)
Hi All
"Identify the behavior of traps, mechanism to implement traps in the snmp framework"
What does it mean?? Can anybody explain.. Whats this Trap??
Thanx in Advance. (1 Reply)
Hi
Our problem is knowing:
What is the "best" way of simulating a TRAP for ERR within a function, since we know this will not work directly with ksh93 and aix5. How can we save the error encountered in the function and then deal with it in the calling script?
Thanks! (3 Replies)
Hello all,
I'm hoping to get a little insight from some of the wily veterans amongst you.
I've written a script to check for new outgoing files to our vendors located on our ssl server. It seems to be working ok, but the final question here, will be one of logic, and/or a better way to... (4 Replies)
My problem is this:
I need to have a catch-all for my processes. An example would be, using a trap, in the parent, to catch any non-0 exit or invalid command (a way to catch core dumps would be cool, too) in not only the parent, but it's children and they're children. Not only that, but I also... (7 Replies)