chadwickh
24th September 2002, 17:56
I had a developer create a script that when run from the UNIX command line like "ba6.1 otccom9999" works great. Unfortunately when run from cron it doesn't because it has to open a terminal device. I've been trying to figure out how to do this without any luck. When typing in "ba6.1 -help" I get :

Usage: ba6.1 [-deftext][-v][-V][-noread][-mdebug][-edebug][-manual][-pipe][-nofields][-logfile][-logmask][-delay][-ld][-pm][-im][-a]

Does anybody know how these options work and what I could do with any UNIX magic?
Here's the log.bshell error:

2002-09-24[10:07:09]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:09]:E:bsp: Log message called from /port.6.1c.06.05/vobs/tt/lib/nw_1/ipc_sock.c: #906 keyword: ipc
2002-09-24[10:07:09]:E:bsp: Pid 29735 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:09]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:09]:E:bsp: Errno 0 bdb_errno 0
2002-09-24[10:07:09]:E:bsp: Log_mesg: 29735 pipe broken in server
2002-09-24[10:07:09]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:09]:E:bsp:
2002-09-24[10:07:09]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:09]:E:bsp: Log message called from /port.6.1c.06.05/vobs/tt/lib/al_1/al_log.c: #1128 keyword: stack trace
2002-09-24[10:07:09]:E:bsp: Pid 29735 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:09]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:09]:E:bsp: Errno 2 (No such file or directory) bdb_errno 0

Here's the log.ba6.1:

2002-09-24[10:07:07]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:07]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:07]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:07]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:07]:E:bsp: Errno 6 (No such device or address) bdb_errno 0
2002-09-24[10:07:07]:E:bsp: Log_mesg: ERROR: Can't open /dev/tty: error 6
2002-09-24[10:07:07]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:07]:E:bsp:
2002-09-24[10:07:07]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:07]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:07]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:07]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:07]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:07]:E:bsp: Log_mesg: ERROR: Can't open stdin&stdout: error 25
2002-09-24[10:07:07]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:07]:E:bsp:
2002-09-24[10:07:07]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:07]:E:bsp: Log message called from /port.6.1c.06.05/vobs/tt/ba/ba/baerror.c: #113 keyword: ba error
2002-09-24[10:07:07]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:07]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:07]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:07]:E:bsp: Log_mesg: Error [BaIntro ]: Can't open display on stdin&stdout for process 0, object 0
2002-09-24[10:07:07]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 6 (No such device or address) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open /dev/tty: error 6
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open stdin&stdout: error 25
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from /port.6.1c.06.05/vobs/tt/ba/ba/baerror.c: #113 keyword: ba error
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: Error [BaCreateMainWindow ]: Can't open display on stdin&stdout for process 0, object 11
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 6 (No such device or address) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open /dev/tty: error 6
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open stdin&stdout: error 25
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 6 (No such device or address) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open /dev/tty: error 6
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open stdin&stdout: error 25
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from /port.6.1c.06.05/vobs/tt/ba/ba/baerror.c: #113 keyword: ba error
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: Error [BaCreateMainWindow ]: Can't open display on stdin&stdout for process 0, object 11
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 6 (No such device or address) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open /dev/tty: error 6
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open stdin&stdout: error 25
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from /port.6.1c.06.05/vobs/tt/ba/ba/baerror.c: #113 keyword: ba error
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: Error [BaCreateMainWindow ]: Process 0 killed
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 6 (No such device or address) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open /dev/tty: error 6
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******
2002-09-24[10:07:08]:E:bsp:
2002-09-24[10:07:08]:E:bsp: ******* S T A R T of Error message *******
2002-09-24[10:07:08]:E:bsp: Log message called from : #0 keyword: curses
2002-09-24[10:07:08]:E:bsp: Pid 29734 Uid 125 Euid 125 Gid 125 Egid 125
2002-09-24[10:07:08]:E:bsp: user_type S language 2 user_name bsp tty locale ISO88591/NULL
2002-09-24[10:07:08]:E:bsp: Errno 25 (Not a typewriter) bdb_errno 0
2002-09-24[10:07:08]:E:bsp: Log_mesg: ERROR: Can't open stdin&stdout: error 25
2002-09-24[10:07:08]:E:bsp: ******* E N D of Error message *******

pconde
24th September 2002, 18:14
hello,

to avoid this problem you can set this session in a job and start the job or via baan or via unix cron

Regards

chadwickh
24th September 2002, 18:24
Then I need to create a session, then a form, then a job, then we have internal procedures I have to deal with such as scheduling and where it runs from, who owns it.

In our startup script, rc.start, we have a call to rc.start_remall which calls "ba6.1 ottstpremall". I wonder how they do it?

patvdv
24th September 2002, 18:38
Did you try putting a TERM definition in front of it?

TERM=vt100 ba6.1 <script>

nick_rogers
24th September 2002, 18:46
what exactly do you mean ? does the session have a form or print something ?

NPRao
24th September 2002, 19:48
chadwickh,

You can have a session without form and attach the 3-GL to it.

The program ottstpremall, removes all the appliation locks then the baan environment is started.

Other option is as Pat advised use the TERM in your shell script.

It would be nice if you can post your code here.

chadwickh
24th September 2002, 22:10
If you run the script below called rc.job_status interactively from a command line it works. If you run it from say cron you get the errors I documented above. We're in a service guard high availability HP-UX cluster that calls this rc.job_status from a cluster package start-up script. I get the same errors from the package startup script as I would running from the bsp crontab:

07 10 * * * . .profile; /4devl/etc/rc.job_status

Here's a script I called rc.job_status:

#!/bin/sh
export TERM=vt100
BSE=/u02/app/baanc/bse
BSE_TMP=/u02/app/baanc/bse/tmp
export BSE BSE_TMP
# Release nbr in variable
REL=6.1
echo 'Change job status flags in ttaad500 table\n'
DS_SERVER=ba
BA_MODE=1
export BA_MODE
export DS_SERVER
filesystem=`echo $BSE | cut -b1-4`
lg=$BSE/log/rc.job_status

echo "============================================================================" >> $lg
echo "Job status flags changed for $BSE on `date`" >> $lg
$BSE/bin/ba${REL} otccom9999
echo "rc.job_status done `date`" >> $lg

exit 0

# end

Here's the tccom9999 Baan script:

|******************************************************************************
|* tccom9999 0 VRC B40U c4 donn
|* Change Job Status
|* us12779
|* 07-19-01 [09:27]
|******************************************************************************
|* Script Type: 0
|******************************************************************************

|****************************** DECLARATION SECTION ***************************

table tttaad500 |Job Table

extern long original.company
extern long retur
extern domain tcmcs.long i
extern domain tcncmp comp(19)

|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
|****************************** CHOICE SECTION ***************************
|****************************** FIELD SECTION ***************************
|****************************** MAIN TABLE SECTION ***************************

function main()
{
original.company = get.compnr()
change.status()
}

|****************************** FUNCTION SECTION ***************************

function change.status()
{
comp(1)= 100 |put values for companies in array
comp(2)= 101
comp(3)= 102
comp(4)= 103
comp(5)= 104
comp(6)= 105
comp(7)= 106
comp(8)= 107
comp(9)= 108
comp(10)= 110
comp(11)= 120
comp(12)= 130
comp(13)= 140
comp(14)= 150
comp(15)= 160
comp(16)= 170
comp(17)= 180
comp(18)= 190
comp(19)= 200

for i = 1 to 19

retur = switch.to.company(comp(i))
if retur = 1 then


db.retry.point()
SELECT ttaad500.jsta
FROM ttaad500 for update
WHERE (ttaad500.user between "edi " and "edizzzzzzzzz"
or ttaad500.user between "e86 " and "e86zzzzzzzzz")
and ttaad500.jsta <> ttaad.jsta.blocked
SELECTDO
ttaad500.jsta = ttaad.jsta.not.active
db.update(tttaad500, db.retry)
SELECTEOS
commit.transaction()
ENDSELECT

endif
endfor
}

chadwickh
24th September 2002, 22:16
What I was getting at regarding the session and form is I was told you need to have a session with a form (with at least an ok button on it) available to be able to run a Baan script from a job. You just can't run a script from a Baan job without a session and form to specify what session the Baan job runs. I was hoping to bypass running a Baan job by just running the object from a shell script.

patvdv
24th September 2002, 22:37
Looks like the object really requires a proper terminal. Maybe you could playing around with the UNIX 'screen' tool.

OmeLuuk
25th September 2002, 09:12
Did you try -- -server : run as a server without UI?

jaapzwaan
25th September 2002, 13:53
Another possibility is the following (works in all releases):

BAMODE=1 ba6.2 -- <object> <args> ...

Regards,

Jaap Zwaan

Juergen
25th September 2002, 15:27
chadwickh,

just an idea, but have you tried to add your script rc.job_status
to a Baan job via the Session ttaad5205m000 (Add shell command to Job)?

Juergen

ssbaan
25th September 2002, 18:32
Did you try running the ba6.1 command in background by using an amperand (&) behind the command? (see below)

$BSE/bin/ba${REL} otccom9999 &

Another thing we do (that may help) is redirect the Unix standand error to a log file of our own

ba6.1 ttaad5203m000 2>${BSE_TMP}/SJOBERR &

chadwickh
25th September 2002, 18:39
1) how do you run the "-- -server" option with ba6.1? All I get is errors saying it's needs a TERM defined..

(btst) on dux013 /4devl/bin$ ba6.1 -- -server otccom9999
ba6.1: Can't open /4devl/lib/terminf/v/vt220: error 2
Error [ba_init_curses ]: init_curses failed
TERM=vt220; TTY=stdin&stdout: No such file or directory; errno = 2

ba6.1: the logfile has been updated with 1 message(s)

(btst) on dux013 /4devl/bin$ ba6.1 -- -set server otccom9999
ba6.1: Can't open /4devl/lib/terminf/v/vt220: error 2
Error [ba_init_curses ]: init_curses failed
TERM=vt220; TTY=stdin&stdout: No such file or directory; errno = 2

ba6.1: the logfile has been updated with 1 message(s)

(btst) on dux013 /4devl/bin$ ba6.1 -- -set -server otccom9999
ba6.1: Can't open /4devl/lib/terminf/v/vt220: error 2
Error [ba_init_curses ]: init_curses failed
TERM=vt220; TTY=stdin&stdout: No such file or directory; errno = 2

ba6.1: the logfile has been updated with 1 message(s)


2) we don't have ba6.2 on our system, BaanIVc4 - we just loaded the 6.1c.06.05 porting set

victor_cleto
25th September 2002, 20:03
To be able to start a ba6.1, it needs TERM to be set to vt100.
On you script, use 'export TERM=vt100' before the ba6.1 command or all in one single line, eg. 'export TERM=vt100; ba6.1 ...'.
Depending on your OS, you may need to split it as 'TERM=vt100; export TERM'.

NPRao
25th September 2002, 20:13
chadwickh,

You can use the ba or bshell followed by your version code with various options.

bshell6.2 -nodebug -server -set BSE_COMPNR=100 -set PACKAGE_COMB=b52astg ozmadmtest

I found more info from my notes -

Ascii mode

To run a 3GL object code from the UNIX command prompt, we use ba6.2. Sometimes it may be required to run ba6.2 without the user interface. How do we do that? set the environment variable BAMODE to 1 and then run ba6.2. Surprisingly, you will not see any interface. The object code will be run silently.
Caution: DO NOT use the function "message()" in the script if it is intended to be run with BAMODE set to 1.

OmeLuuk
25th September 2002, 22:51
Where is the use of BAMODE=1 documented by Baan? (want to add it's description to my list...)

NPRao
25th September 2002, 23:16
OmeLuuk,

You can refer to the $BSE/etc/rc scripts for its usage.

Sure you can add to the list.


BAMODE=1
|* No output to screen

chadwickh
25th September 2002, 23:48
Thanks everyone especially NPRao, the bshell6.1 with the -server option works great.

Here's what I run from an $BSE/etc/rc startup script running from cron or package startup scripts that doesn't have any terminal output:

$BSE/bin/bshell6.1 -nodebug -server -set BSE_COMPNR=100 -set PACKAGE_COMB=DONN otccom9999

:)