Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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 want to run an editor in the background with commands stuffed into its input. this is being run in a script i want to run under cron. the editor never exits. it works fine at the command line and under the script command. but under cron the editor freezes. i tried under script under cron and script freezes.
the script that runs the editor does get started by cron. so this much is not an issue. i can see the editor process has started. the editor is waiting for something. the script is waiting for the editor to finish. if i kill the editor the script wakes up and does everything after that point. i think the editor is expecting a real tty or at least a virtual one. i looked through the cron manual and i don't see a way to give it a tty.
the script that runs the editor does get started by cron. so this much is not an issue. i can see the editor process has started. the editor is waiting for something. the script is waiting for the editor to finish. if i kill the editor the script wakes up and does everything after that point. i think the editor is expecting a real tty or at least a virtual one. i looked through the cron manual and i don't see a way to give it a tty.
and - if theoretically - there will be a tty attached how do you want to access it (how do you know about it at all)?
What is the goal to start an editor from cron?
what editor are you using? As an aside, if you tell us what you are actually trying to do someone may be able suggest an alternative approach.
Evo2.
it doesn't matter what editor. this happens with more than one editor and also with some other programs when they get a pipe or file as stdin.
i am trying to get every program that can't or won't operate correctly in the background to do so, so they all can be used in scripts where their normal action in an interactive shell matches what the script needs to have done.
and - if theoretically - there will be a tty attached how do you want to access it (how do you know about it at all)?
What is the goal to start an editor from cron?
the goal is not to start an editor.
the goal is to start a script that invokes a program that behaves differently or badly when it cannot access a tty.
i am trying to get every program that can't or won't operate correctly in the background to do so
That is wrong. Every app needs an environment to be able to work properly. Probably a few environment variables (like PATH, DISPLAY, .../), or a dir (or file) (like config file), some devices (like tty) are required. It is completely irrelevant if it was started in the foreground or background.
That is wrong. Every app needs an environment to be able to work properly. Probably a few environment variables (like PATH, DISPLAY, .../), or a dir (or file) (like config file), some devices (like tty) are required. It is completely irrelevant if it was started in the foreground or background.
how do you get that environment in the background? how do you get ...
i am trying to get every program that can't or won't operate correctly in the background to do so
That seems a very general question and quite different to the question you originally asked. It also would seem to me to be near impossible to answer. The word *every* is problematic.
how do you get that environment in the background? how do you get ...
Sorry guy, I don't really understand. There is no direct way to access to any other process to inspect it. That would be a security hole. From the other hand you can check /proc/<pid> (see the proc filesystem). But again I still don't really understand what is it all about.
Probably you are speaking about a debugger for shell scripts, I don't know.
For me it looks like you want to catch a specific type of error, but would be better to explain it instead of discussing this editor thing - you are on the wrong track. (but again, I don't really understand).
If you want to "run a child process and stuff information into its STDIN," how exactly is this different from the "pipe (|)" facility that the shell already has? Or, as the case may be, "tee?"
Last edited by sundialsvcs; 05-04-2021 at 03:30 PM.
If you want to "run a child process and stuff information into its STDIN," how exactly is this different from the "pipe (|)" facility that the shell already has? Or, as the case may be, "tee?"
many programs can detect if this is a tty or not (controlling tty ?). so it needs an environment where that exists along with the related info such as the screen width and height. the stty -a command shows most of this info. if it can't get what it wants while in that environment then it fails in some way. i think at least one editor created its own /dev/tty and stuck waiting for input that would never come in unless typed at the terminal. but under a cron script, there is no terminal.
maybe what we need is a cron daemon that creates a tty environment much like the script command and either gives it specified input or runs a process that decides the input. that would make for more features in the crontab. ...just an idea.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.