If anyone has a moment to spare, I have a quick question for the community. For the record, I'm running Xubuntu 12.04...
Based on a few hours' digging about, I've created an executable test script, "test.sh" which incorporates the following code:
The object is to check every second to determine if a certain process is running; and, if it is, fire off a warning dialog for the user to dismiss. The script is then to wait around in the background until the process has been closed by the user; at which time it returns to its original standby mode.
However, for the life of me, I can't seem to get the above code to work. Gotta be a drop-dead simple thing syntaxwise; but it simply has eluded me thus far...
Any suggestions for the noob?
Thanks a bunch!
Last edited by LinQ; 02-10-2014 at 05:14 PM..
Reason: Code spiff ;)
I'm not sure I understand what you want to achieve with your script. Calling those functions recursively without an exit branch is not the right way. Some point in time that will blast the stack. Why don't you create one single loop with an exit condition, and in that loop you sleep, test for that process, and run zenity warning if condition met?
BTW, you second redirection seems wrong.
With the collective input, I got this to work well:
However, now I'm really concerned about what RudiC said: Will I wind up running off the stack with the above code? Seems like it's all just going about in a slow, quiet loop.
Your calls to holdSeq and runSeq are not like goto statements they are function calls which push the previous state onto a stack the flow of control never reaches the end of either of these functions before calling another instance.
Consider this alternative:
This User Gave Thanks to Chubler_XL For This Post:
@Chubler_XL:
Thanks for the heads up here. Good code...
"Thanks" for everyone, too
However, this raises one last question concerning the OP:
Out of curiosity, is there some way of resetting/clearing the stack in an instance like this with an explicit call?
Or, is there a garbage collection function which can be accessed and called on the fly???
There is no magic function you can call to unwind a stack when your functions never return.
You could overlay the current process with a fresh copy of itself by replacing the lines at the end of your file:
with:
Note that the last line of this script will never be reached and can, therefore, be removed and not affect the behavior of this script.
Obviously, Chubler_XL's script is a much better approach. Unless each recursive call in your original script is replaced by an exec call, there is no guarantee that the appropriate state changes will occur to get you to an exec call before you run out of stack space.
This User Gave Thanks to Don Cragun For This Post:
Hi,
I'm looking at doing a cron job for a script that could take a very short time to complete or a very long time to complete based on variable activity on a server. I don't want to do a weird schedule, but I don't want to be so aggressive that the process attempts to start before another... (14 Replies)
Hello,
I need to compare two flat files (ASCII format), say file OLD and file NEW. Both have similar structure. These files are | delimitted files and have around few million of records (lines) each. Each file has same set columns and same set of key columns (i.e. the 3rd and 5th column of the... (7 Replies)
Hey, for the purpose of a research project I need to know if a specific type of parallel processing is being utilized by any user-run programs. Is there a way to detect whether a program either returns a value to another program at the end of execution, or just utilizes any form of parallel... (4 Replies)
hellou, can anybody help me with nat detection in real time ? i prefer some detection script because i try some nat detection program's for example p0f or i'm using tcpdump, but i would get contain of specific packet. Some ideas? (1 Reply)
Hi all,
i am new to scripting. i need to write a code to detect begin and end of word that either begins or ends with t,th,d,dh,s,sh
i have a set of words in a file containg one word per line. let the filename be aaa.txt.
i have an another file bbb.txt which has two lines, just specifying the... (7 Replies)
How to get information that where is my modem configured in /dev.
I have two modems configured in my device .. one is USB and other is PCI modem.. USB is detected as /dev/USB0. but how to see about PCI modem? (0 Replies)
I am piping STDOUT from commands such as ifconfig and dmesg through grep, sed and awk to get the information I need.
I need to now perform some looping and branching now and have been trying to figure out how to do this on the command line.
You may ask "Why the command line? - Why not put it... (2 Replies)
IS there virus software for unix? I worked in a Solaris environment and dont remember having anything. I also ask because the current enviroment i am working on is Microsoft and they argue that they do not use unix because of virus detection. Any input would be greatly appreciated. (1 Reply)