ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a bourne shell script with a menu. One menu entry is for running an executable to produce output on the screen. How can I stop this program and get kicked back to my script (menu)? So far all I can do is Ctrl-C which kicks me back to my command prompt. I am using the bash shell on OpenBSD.
Well the executable is one that continues to show output (it shows logs of a busy server). So putting it in the background does not help. I already tried this before posting and I get back to my menu but of course the output crashes through. Although I did not try the disown command.
You should post that script here, it is kinda hard to give examples how to modify that script without seeing it
Yes I'd agree and perhaps you can also post the necessary outputs if you like. I think I can give a solution to your problem as I made a big bunch of scripts similar to your script but I'd like to see the code first.
If the operating system on which bash is running supports job control, bash contains facilities to use it. Typing the suspend character (typically ^Z, Control-Z) while a process is running causes that process to be stopped and returns control to bash. Typing the delayed suspend character (typically ^Y, Control-Y) causes the process to be stopped when it attempts to read input from the terminal, and control to be returned to bash. The user may then manipulate the state of this job, using the bg command to continue it in the background, the fg command to continue it in the foreground, or the kill command to kill it. A ^Z takes effect immediately, and has the additional side effect of causing pending output and typeahead to be discarded.
Suspending the running process wouldn't help at all. That would effectively bring the user back to the command prompt. You may not have grasped what I'm trying to do here. Reread my first post and report back.
No need to get sarcastic; I did grasp what you are trying to do, but since you didn't post your entire script, or better yet a working subset of it, I had no way to test my idea on your code.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.