• crontab problem

    From Vincent Coen@2:250/1 to All on Thu Mar 26 14:05:12 2020
    Hello All!

    I am attempting to run a process written in Cobol using the Gnu Cobol
    compiler and keep getting the follow when trying to run it:

    Error opening terminal: unknown.

    On the assumption that it is trying to run an application called terminal
    which no longer exists how do I change the preset of that to what I do have installed which is qterminal.

    Just can see any where within /etc/cron ... that does so nor does the man crontab help.

    I am running Magiea v7 X64 with all updates.


    Vincent


    SEEN-BY: 250/1 3
  • From Bit Twister@2:250/1 to All on Thu Mar 26 14:41:19 2020
    On Thu, 26 Mar 2020 14:05:12 +0000, Vincent Coen wrote:
    Hello All!

    I am attempting to run a process written in Cobol using the Gnu Cobol compiler and keep getting the follow when trying to run it:

    Error opening terminal: unknown.

    It might have helped to show how you are getting cron to run whatever
    you are doing.

    I have seen some of my scripts complain about terminal things.
    Since I want my scripts to run in cron or interactively, I test that
    if running in cron, go ahead and set some terminal values.
    all my scripts include a function/file to set desired default variables.

    So here is a snippet from that include file:

    tty --silent
    export _cron_flg=$? # $?=0 interactive $?=1 cron

    if [ $_cron_flg -eq 1 ] ; then
    export COLUMNS=80
    export LINES=24
    export TERM=vt420
    fi

    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Vincent Coen@2:250/1 to Bit Twister on Thu Mar 26 17:58:29 2020
    Hello Bit!

    Thursday March 26 2020 14:41, Bit Twister wrote to All:

    On Thu, 26 Mar 2020 14:05:12 +0000, Vincent Coen wrote:
    Hello All!

    I am attempting to run a process written in Cobol using the Gnu
    Cobol compiler and keep getting the follow when trying to run it:

    Error opening terminal: unknown.

    It might have helped to show how you are getting cron to run whatever
    you are doing.

    I have seen some of my scripts complain about terminal things.
    Since I want my scripts to run in cron or interactively, I test that
    if running in cron, go ahead and set some terminal values.
    all my scripts include a function/file to set desired default
    variables.

    So here is a snippet from that include file:

    tty --silent
    export _cron_flg=$? # $?=0 interactive $?=1 cron

    if [ $_cron_flg -eq 1 ] ; then
    export COLUMNS=80
    export LINES=24
    export TERM=vt420
    fi


    Do not fully understand the above but the program uses ncurses so runs in a terminal and I use qterminal as that is one of the few available in the
    repos.

    Checking it in via control center, software says :

    QT-based multitab terminal emulator. Based on QTermWidget

    Executing program uses 80 x 24 lines but does not need any response from a
    user as it takes input from files only.

    The crontab shows :

    #Hourly
    00 0-23 * * * $HOME/etc/hourly
    10 0-23 * * * $HOME/bin/run-elist.sh UPDATE ALL SKIP-PASSWORD

    It is the last line as the one before does the same error and I am trying
    to find a fix ?

    The content of the file run-elist.sh is :

    #!/bin/bash
    # 24/02/2020 vbc - v1.00 created
    # 23/03/2020 vbc - v1.01 removed the exit RT so it get to top level for
    testing
    # when I get around to it.
    #
    cd /home/mbse/elist

    if [ ! -d backups ]; then
    mkdir backups
    fi
    if [ ! -d rules ]; then
    mkdir rules
    fi
    if [ ! -d originals ]; then
    mkdir originals
    fi
    #
    #if [ $1 == ""]; then
    # echo "No paramter given - Aborting"
    #fi
    #export COB_TRACE_FILE=/home/mbse/trace.log
    #export COB_SET_TRACE=TRUE
    # NEXT ONE for building or running Regression tests in REPORT
    #export COB_CURRENT_DATE="2020/02/29 23:45:00"
    #export LC_TIME=en_GB
    #
    /home/mbse/bin/elist $1 $2 $3 $4
    exit

    The first two export lines are some times set if I am debugging the program elist.

    As you can see there are 3 params passed to elist UPDATE ALL SKIP-PASSWORD

    If I run it manually from the kde screen I load qterminal which is preset
    to use 80 wide by 40+ lines long then run the same script ( run-elist.sh ).

    Comes to EOJ as expected, it is just trying to run it automatically every
    hour this error comes up so I am assuming crontab find out it needs a
    terminal to run in but has 'terminal' preset as the tool to use and in may
    case instead of 'qterminal'.

    So the issue seems to be possibly fixed if I can tell cron to run the right terminal program that in turns runs elist via script run-elist.sh.

    Have I explained it better now ?



    Vincent


    SEEN-BY: 250/1 3
  • From David W. Hodgins@2:250/1 to All on Thu Mar 26 19:26:53 2020
    On Thu, 26 Mar 2020 13:58:29 -0400, Vincent Coen <VBCoen@gmail.com> wrote:
    Thursday March 26 2020 14:41, Bit Twister wrote to All:
    So here is a snippet from that include file:
    tty --silent
    export _cron_flg=$? # $?=0 interactive $?=1 cron

    if [ $_cron_flg -eq 1 ] ; then
    export COLUMNS=80
    export LINES=24
    export TERM=vt420
    fi


    Do not fully understand the above but the program uses ncurses so runs in a terminal and I use qterminal as that is one of the few available in the repos.

    The script is simply setting variables some programs expect, if it's running in
    interactive mode.

    As cron jobs must be able to run without a tty (i.e. terminal), that script will
    not help with running a program that accesses a tty.

    The cron job may work with redirection ...
    somecommand > /somefile.txt 2>&1 0</dev/null
    but if the program uses direct i/o for the terminal, that will also fail, in which
    case the answer is that the program simply can not be run as a cron job.

    Another option might be to always leave a user logged in, and run the job using
    a script in an open terminal, such as konsole that runs the program every hour.

    Regards, Dave Hodgins


    --
    Change dwhodgins@nomail.afraid.org to davidwhodgins@teksavvy.com for
    email replies.

    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Vincent Coen@2:250/1 to David W. Hodgins on Thu Mar 26 23:43:44 2020
    Hello David!

    Thursday March 26 2020 19:26, David W. Hodgins wrote to All:

    Do not fully understand the above but the program uses ncurses so
    runs in a terminal and I use qterminal as that is one of the few
    available in the repos.

    The script is simply setting variables some programs expect, if it's
    running in interactive mode.

    As cron jobs must be able to run without a tty (i.e. terminal), that
    script will not help with running a program that accesses a tty.

    Nope, the program runs totally stand alone once per hour.
    It looks for two file extensions of .ECO and .RUL
    It does a ls *.ECO *.eco *.rul *.RUL > fred
    It them process fred and for each file present processes it updating a
    database and may be produces report files.

    That is it. For now I am trying an experiement having done a
    ln -sf /usr/bin/qterminal /usr/bin/terminal

    I will see in 15 minutes if it works but as it was possibly an easy fix I
    am not holding my breath.

    The cron job may work with redirection ...
    somecommand > /somefile.txt 2>&1 0</dev/null
    but if the program uses direct i/o for the terminal, that will also
    fail, in which case the answer is that the program simply can not be
    run as a cron job.

    Another option might be to always leave a user logged in, and run the
    job using a script in an open terminal, such as konsole that runs the program every hour.

    That may well be the way I have to do it but then have to find a way of
    doing just that - running the script once per hour.
    Will be a pity if I have to have a user account open as it could be a bit
    of a security hole.

    Regards, Dave Hodgins


    Thanks for the suggestion.


    Vincent


    SEEN-BY: 250/1 3
  • From Bit Twister@2:250/1 to All on Fri Mar 27 00:50:14 2020
    On Thu, 26 Mar 2020 17:58:29 +0000, Vincent Coen wrote:
    Hello Bit!

    Thursday March 26 2020 14:41, Bit Twister wrote to All:

    On Thu, 26 Mar 2020 14:05:12 +0000, Vincent Coen wrote:
    Hello All!

    I am attempting to run a process written in Cobol using the Gnu
    Cobol compiler and keep getting the follow when trying to run it:

    Error opening terminal: unknown.

    It might have helped to show how you are getting cron to run whatever
    you are doing.

    I have seen some of my scripts complain about terminal things.
    Since I want my scripts to run in cron or interactively, I test that
    if running in cron, go ahead and set some terminal values.
    all my scripts include a function/file to set desired default
    variables.

    So here is a snippet from that include file:

    tty --silent
    export _cron_flg=$? # $?=0 interactive $?=1 cron

    if [ $_cron_flg -eq 1 ] ; then
    export COLUMNS=80
    export LINES=24
    export TERM=vt420
    fi


    Do not fully understand the above but the program uses ncurses so runs in a terminal and I use qterminal as that is one of the few available in the repos.

    Just paste the above before or after your
    cd /home/mbse/elist
    line.

    You may need to change export TERM=vt420 whatever you see with
    echo $TERM
    in your current terminal.

    I can see this is commented out, but you need to have an exit Some_number_here Suggest you always have one. You also have a problem with the if statement. Sample fix to you code. :)

    #if [ $1 == "" ]; then
    # echo "No parameter given - Aborting"
    # exit 1
    #fi

    All my scripts have
    set -u # Show usage of unset variables as an error to help catch typos.


    Since you are using
    /home/mbse/bin/elist $1 $2 $3 $4
    I would have something like
    if [ $# -ne 4 ]; then
    echo "
    Incorrect number of arguments: $#
    There should be 4 arguments
    "
    exit 1
    fi

    Problem with my suggestion is your cron job is running with just
    3 arguments. :(

    Easy fix
    _required_args=4
    if [ $_cron_flg -eq 1 ] ; then
    _required_args=3
    if

    if [ $# -ne $_required_args ]; then
    echo "
    Incorrect number of arguments $#
    There should be $_required_args arguments
    "
    exit 1
    fi

    Suggest you change
    from /home/mbse/bin/elist $1 $2 $3 $4
    to $HOME/bin/elist $1 $2 $3

    If you use set -u

    Checking it in via control center, software says :

    QT-based multitab terminal emulator. Based on QTermWidget

    Executing program uses 80 x 24 lines but does not need any response from a user as it takes input from files only.

    The crontab shows :

    #Hourly
    00 0-23 * * * $HOME/etc/hourly
    10 0-23 * * * $HOME/bin/run-elist.sh UPDATE ALL SKIP-PASSWORD

    It is the last line as the one before does the same error and I am trying
    to find a fix ?

    The content of the file run-elist.sh is :

    #!/bin/bash
    # 24/02/2020 vbc - v1.00 created
    # 23/03/2020 vbc - v1.01 removed the exit RT so it get to top level for testing
    # when I get around to it.
    #
    cd /home/mbse/elist

    if [ ! -d backups ]; then
    mkdir backups
    fi
    if [ ! -d rules ]; then
    mkdir rules
    fi
    if [ ! -d originals ]; then
    mkdir originals
    fi
    #
    #if [ $1 == ""]; then
    # echo "No paramter given - Aborting"
    #fi
    #export COB_TRACE_FILE=/home/mbse/trace.log
    #export COB_SET_TRACE=TRUE
    # NEXT ONE for building or running Regression tests in REPORT
    #export COB_CURRENT_DATE="2020/02/29 23:45:00"
    #export LC_TIME=en_GB
    #
    /home/mbse/bin/elist $1 $2 $3 $4
    exit

    The first two export lines are some times set if I am debugging the program elist.

    As you can see there are 3 params passed to elist UPDATE ALL SKIP-PASSWORD

    If I run it manually from the kde screen I load qterminal which is preset
    to use 80 wide by 40+ lines long then run the same script ( run-elist.sh ).

    Comes to EOJ as expected, it is just trying to run it automatically every hour this error comes up so I am assuming crontab find out it needs a terminal to run in but has 'terminal' preset as the tool to use and in may case instead of 'qterminal'.

    So the issue seems to be possibly fixed if I can tell cron to run the right terminal program that in turns runs elist via script run-elist.sh.

    Have I explained it better now ?



    Vincent




    --
    The warranty and liability expired as you read this message.
    If the above breaks your system, it's yours and you keep both pieces.
    Practice safe computing. Backup the file before you change it.
    Do a, man command_here or cat command_here, before using it.

    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From David W. Hodgins@2:250/1 to All on Fri Mar 27 02:28:35 2020
    On Thu, 26 Mar 2020 19:43:44 -0400, Vincent Coen <VBCoen@gmail.com> wrote:

    That may well be the way I have to do it but then have to find a way of
    doing just that - running the script once per hour.
    Will be a pity if I have to have a user account open as it could be a bit
    of a security hole.

    Running it once per hour is easy. Have whatever desktop environment's autostart
    run the script at login, in a terminal. Have the first executable line of the script be ...
    echo "$0" | at now + 1 hour 2> /dev/null

    That will run that script every hour. If you logout, the script will still
    run, but will fail as the terminal will have closed.

    If you want to stop the script running, open another terminal, use the
    atq command to get the job number that's currently waiting to run and use
    atrm $jobnumber
    to stop it.

    I don't remember off hand whether or not the "at" package is installed by default.

    Regards, Dave Hodgins

    --
    Change dwhodgins@nomail.afraid.org to davidwhodgins@teksavvy.com for
    email replies.

    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From David W. Hodgins@2:250/1 to All on Fri Mar 27 02:32:17 2020
    On Thu, 26 Mar 2020 22:28:35 -0400, David W. Hodgins <dwhodgins@nomail.afraid.org> wrote:

    On Thu, 26 Mar 2020 19:43:44 -0400, Vincent Coen <VBCoen@gmail.com> wrote:

    That may well be the way I have to do it but then have to find a way of
    doing just that - running the script once per hour.
    Will be a pity if I have to have a user account open as it could be a bit
    of a security hole.

    Running it once per hour is easy. Have whatever desktop environment's
    autostart
    run the script at login, in a terminal. Have the first executable line of
    the
    script be ...
    echo "$0" | at now + 1 hour 2> /dev/null

    Forgot to add, just lock the screen with that konsole or terminal still open, if you're leaving the system running unattended.

    Regards, Dave Hodgins

    --
    Change dwhodgins@nomail.afraid.org to davidwhodgins@teksavvy.com for
    email replies.

    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From William Unruh@2:250/1 to All on Fri Mar 27 15:41:23 2020
    On 2020-03-26, Vincent Coen <VBCoen@gmail.com> wrote:
    Hello David!

    Thursday March 26 2020 19:26, David W. Hodgins wrote to All:

    Do not fully understand the above but the program uses ncurses so
    runs in a terminal and I use qterminal as that is one of the few
    available in the repos.

    The script is simply setting variables some programs expect, if it's running in interactive mode.

    As cron jobs must be able to run without a tty (i.e. terminal), that
    script will not help with running a program that accesses a tty.

    Nope, the program runs totally stand alone once per hour.
    It looks for two file extensions of .ECO and .RUL
    It does a ls *.ECO *.eco *.rul *.RUL > fred
    It them process fred and for each file present processes it updating a database and may be produces report files.

    ??? The program is designed to take information from the terminal and
    give output to the terminal. When you start it, or the script, it looks
    for the terminal, by looking at your environment. It finds nothing and
    says AAAAARGH and issues the error message and gives up.
    As stated, try redirecting the stdin stdout stderr (stdout and stderr
    should be OK since they get redirected to the mailer in cron but stdin
    is NOT OK. There is NO default it can use to get input. The program says
    it wants input, there is nothing (no terminal) to get input from.
    As Hodgin suggests, try redirecting 0 and see if that works. But the
    program may specifically try to open a terminal and find none.

    Try doing in a terminal
    env|grep TERM

    I get TERM=xterm-256color
    But in cron that veriable is not set.
    Another thing you could try (I have no idea whatsoever if this would
    work) is to set the environment variable in teh cron entry as above
    5 * * * * TERM=xterm-256color; <your command> 0</dev/null


    That is it. For now I am trying an experiement having done a
    ln -sf /usr/bin/qterminal /usr/bin/terminal

    I will see in 15 minutes if it works but as it was possibly an easy fix I
    am not holding my breath.

    The cron job may work with redirection ...
    somecommand > /somefile.txt 2>&1 0</dev/null
    but if the program uses direct i/o for the terminal, that will also
    fail, in which case the answer is that the program simply can not be
    run as a cron job.

    Another option might be to always leave a user logged in, and run the
    job using a script in an open terminal, such as konsole that runs the program every hour.

    That may well be the way I have to do it but then have to find a way of
    doing just that - running the script once per hour.
    Will be a pity if I have to have a user account open as it could be a bit
    of a security hole.

    Regards, Dave Hodgins


    Thanks for the suggestion.


    Vincent



    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)