LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 04-25-2021, 07:10 PM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
run an editor inn the background


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.

any suggestions?
 
Old 04-25-2021, 07:20 PM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Set $PATH for your script or use full path with commands ?
 
Old 04-25-2021, 08:28 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
Have you checked the log files? They might shed some light on this.

Per this thread from askubuntu, check /var/log/syslog.
 
Old 04-25-2021, 11:53 PM   #4
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
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.
 
Old 04-26-2021, 12:17 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

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.
 
Old 04-26-2021, 12:25 AM   #6
igadoter
Senior Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: many, primary Slackware
Posts: 2,717
Blog Entries: 1

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
This was done already - ed - batch editor - it stream version is known as sed. Ed is truly editor. Not like sed or awk. You can jump on all the file.
 
Old 04-26-2021, 03:50 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by Skaperen View Post
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?
 
Old 04-27-2021, 07:19 PM   #8
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by evo2 View Post
Hi,

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.
 
Old 04-27-2021, 07:25 PM   #9
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by pan64 View Post
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.
 
Old 04-28-2021, 01:14 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by Skaperen View Post
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.
 
Old 05-03-2021, 03:13 PM   #11
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by pan64 View Post
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 ...
 
Old 05-03-2021, 05:33 PM   #12
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by Skaperen View Post
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.

Evo2.
 
Old 05-04-2021, 01:41 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by Skaperen View Post
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).
 
Old 05-04-2021, 03:29 PM   #14
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.
 
Old 05-13-2021, 08:10 PM   #15
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by sundialsvcs View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
don't forget INN ..... cuix Linux - Software 2 07-16-2004 01:07 PM
how to configure News Server in Linux usin INN anilmpg Linux - Newbie 0 05-26-2004 05:36 AM
how to set up inn vasu Linux - Networking 1 12-01-2003 01:01 AM
Inn Jim Morris General 1 10-21-2003 10:38 AM
NNTP, INN Info?? deepika Linux - General 1 09-26-2003 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration