Badre Alam
18th May 2002, 07:01
I would like to call unix shell script thru DEM, what are the possibilities. As thru Menu I got it done how this will achived thru DEM ?
can any one pls give the proper syntax of run.baan.prog(), as it is asks for 6 argumentgs, how to pass args. to this function.
Thanks
Alam Badre
NPRao
18th May 2002, 10:00
The run.baan.prog has only 3 arguments, here is the help info -
Syntax
long run.baan.prog( const string progname, const string arguments, long mode )
long run.prog( const string progname, const string arguments, long mode )
Description
The function run.baan.prog() runs a BAAN program.
The function run.prog() runs an operating system command. It is a system-dependent function. It must not be used in applications that are distributed across different platforms.
Arguments
progname The name of the program or command to be executed. run.baan.prog() expands progname to $BSE/bin/progname{release}. If the progname argument in run.prog() does not supply the full path (absolute or relative), the system searches for the command using the standard facilities of the operating system platform (for example, under UNIX, all PATH elements are searched).The argument can specify a remote host. For example, if progname is tahoe!sort, the function runs the sort program on the tahoe host. The maximum number of remote programs that can run concurrently depends on available system resources.
arguments The function start the program or command with the parameters specified here.
mode This specifies the execution mode of the program or command. The possible values are:RP_WAIT wait for the program to finish
RP_NOWAIT run as a background program
Note
Output from the program cannot be displayed. If the -q switch is available, use this to output the program results to a file.
Use these functions instead of the shell() function used in previous versions of BAAN.
Return values
0 program executed successfully
<0 program could not be started
>0 program did not execute successfully
Note that the return value cannot be retrieved when the mode argument is set to RP_NOWAIT.
Context
Bshell function.
Badre Alam
18th May 2002, 13:35
r=run.prog ("sh /bin/chg.sh","",0)
r=run.prog ("sh /bin/chg.sh",logname$,0)
r=run.prog ("sh /bin/chg.sh","",RP_NOWAIT)
I tried to execute the run.prog() as mentioned above, getting no error during compilation but the shell script is not executing.
permissons to read/execute the file are proper.
can u pls. suggest ?
Thanks
Alam Badre
NPRao
18th May 2002, 19:38
Hi Alam,
change your code as -
e=run.prog ("/bin/chg.sh","",0)
e=run.prog ("/bin/chg.sh",logname$,0)
e=run.prog ("/bin/chg.sh","",RP_NOWAIT)
you can also use as -
string comd(256)
comd = "/bin/chg.sh " & logname$
e = shell(comd, 0)
Badre Alam
21st May 2002, 09:06
comd = "sh /bin/chg.sh " |& logname$
r = shell(comd, 0) |1
I chkd-up all the possibilities as u suggested but none of them is working except above mentioned but still "shell()" is not executing the shell script, when I chkd-up the processes it shows running "ottstpvtemul" but not executing the script.
As "ottstpvtemul" is runing as the back-end process what I want this should pop-up as user press "continue.." button, so that unix shell script can be executed after getting inputs from user.
Thanks
Alam Badre
NPRao
21st May 2002, 09:27
Hi Alam,
To get the confirmation, you have to use the option with shell as -
SHELL_CONFIRM Displays the message "Press RETURN", or its local equivalent, in the right lower corner of the window after the shell process has finished.
or
SHELL_MWINDOW A main window is created. This displays the output of the shell command.
Please check the return values -
Return values
>0 return code of command
0 success
-1 maximum number of pty's is reached; general error code
-2 cannot open the master pty
-3 pipe command failed
-4 fork of reader process or shell process failed
-6 cannot start terminal emulator
It will help in debugging the problem.
Can you please clarify what do you mean by thru DEM -
I would like to call unix shell script thru DEM, what are the possibilities. As thru Menu I got it done how this will achived thru DEM ?
Badre Alam
21st May 2002, 09:41
Great.............
I got it done by using SHELL_MWINDOW. Thanks alot....
As in BaaN we are having options for menu either standard Menu or customised DEM (Dynamic Enterprse Modellar), and with DEM we can attached any Roles which is having business processes / utilities / manual activity etc .. attached to it.
Actually my intention was that every user can change their passwd thru BaaN without going to Shell prompt, change of passwd requires at Unix level as well as on Informix level, so script is directly executing from BaaN session and ask for users "old passwd" and then "new passwd".
once again thank you very much for your kind support.
Rgds
Alam Badre
NPRao
21st May 2002, 09:50
Hi Alam,
We faced a bit similar situation that we need to give access to the user to change password but no shell access/ksh/sh and we didnt like the baan password aging too (which doesnt work well).
so I made a 3-GL script, attached to a session, with no forms,
the script is simple - call the Unix password command -
function main()
{
e = shell("passwd", 0)
}
it asks for the old and new password, and exits if the user tries to be smart, to press control-c, or when the new passwords dont match etc.
Just curious- :confused: I dont know why are you giving the users the access to change their informix/database passwords.
Badre Alam
21st May 2002, 10:17
nothing dangerous as user does not have direct access to the shell and this is limited to the user's, they can't change passwd of others, even they don't have direct access to informix to change the passwd or access the database thru shell, this is well restricted thru Unix.
Just because of company policy as suggested by PWC (Price Waterhouse Coopers) after auditing.
Thanks
Alam Badre
manusatsangi
22nd May 2002, 15:28
Hi NPRao,
Regarding the syntax of run.baan.prog which you gave, I presume it is available as an external function of a dll. Is it true?
'Cause I didn't find it in standard functions.
As specified in the syntax, "Output from the program cannot be displayed", I tried to redirect output to file as follows:
ret = run.baan.prog("licmon", "-w > c:/foo/bar")
Though, ret value was 0 (which means success) but no file created c:/foo/bar :(
Does that mean redirection to a file cannot be done?
Another question, where can I get a repository of useful functions (and their syntax) which are hidden inside dlls.
Warm Regards
Manu
NPRao
22nd May 2002, 19:28
Hi Manu,
Thats a BaaN standard function available in the tools dll - ttdllbw.
you can use only the functions from the tools dlls or your own developed dlls if only they are defined as extern or used as includes.
I dont know which version of BaaN are you working on, you can use the sessions -
ttstpbaandoc (or) ttstpobjinfo (this is similar to the option of using $BSE/bin/bic_info6.2 [or your baan version])
I prefer the shell() function to the run.baan.prog(). But BaaN tools manual advises -
Notes
This function is supported for backward compatibility only. In new applications, use run.prog() and run.baan.prog() instead.
The function is available only for programs running under UNIX, and not for programs running under Windows NT.
I never worked on BaaN installation on Windows, so for portability issues I guess you might have to use run.baan.prog() than the shell().
I did use the run.baan.prog which gave me an output file, but I guess there was an output redirect for that binary to facilitate that.
comd = "bic_info"
options = " -u " & "o" & ttadv230.cpac &
ttadv230.cmod & strip$(ttadv230.cprs) & " -qo " & fpath
e = run.baan.prog(comd, options, RP_WAIT)
The other issue I see with your coding is that you have use c:/foo/bar. The "/" is more unix like and not windows, if you are working on windows then you have to use c:\foo\bar
Hope this helps you to fix your problem.
manusatsangi
23rd May 2002, 10:05
Hi NPRao,
We are on WIn 2K server, BaaN IV c4, Oracle 8i
I checked with 'bic_info -e ottdllbw', but did not find run.baan.prog function in it.
Moreover, what I wanted to ask is that in case I need detailed syntax of function app_start, I can get only the definition thru bic_info.
How do I get the detailed syntax?
NPRao
23rd May 2002, 20:03
Hi Manu,
I guess its my oversight, the run.baan.prog() is a baan standard function. It is not present in the ttdllbw DLL. I think I had app_start() in my mind when it was writing the post, which is present in the tools DLL ottdllbw.
I was explaining an example to see the function prototypes and the dll usages with the bic_info command -
you can use like this on Windows -
>bic_info6.2 ottdllbw | more
[use your baan version]
then you can see all the object info, function protypes, descriptions etc.
You can see the syntax of app_start() function, bic_info on the tools DLL, ottdllbw
Here is the info from help manual -
Syntax
long app_start( string commandline, string directory, string stdin, string stdout, string stderr )
Description
This starts the application specified in the commandline argument. It returns an ID for the started application. You can subsequently use this ID as the app.id argument in the app_status() function.
Arguments
commandline This specifies the command that starts the application. If commandline does not include a directory path, Windows searches for the executable file in the following directories, in the order shown below:1 The directory where BW is loaded.2 The Windows system directory.3 The Windows directory.4 The directories listed in the PATH environment variable.
directory The default working directory for the application.
stdin The standard input file name.
stdout The standard output file name.
stderr The standard error file name.
Notes
If commandline specifies the name of a nonexecutable file, Windows starts the application with which the file name extension is associated. For example, if commandline is c:\temp\file.txt, and .txt is associated with the Notepad application, Windows will start Notepad. Because users can change the association of a file name extension, you cannot predict which application will start.
This functionality is not available when you specify standard input, output, and error files.
Return values
>=0 success; identification number of the started application is returned
<0 error (that is, the negative value of the system error)
Context
ttdllbw library function.
ericthomas
10th February 2004, 15:45
I read the thread. We have a similiar requirement.
We need to enable password aging in UNIX. so Baan users to change as and when it expires. How we can do it?
Please write an overview of how it can be achieved?
many thanks,
Eric.
dorleta
11th February 2004, 12:38
the standard solution:
function extern long tgwms0004.start.application(const string application(),
const string arguments (),
domain tgyenox local,
long mode,
[long pop_up])
{
DLLUSAGE
This function starts the application with the given arguments. The given
application may not be empty, the arguments may be empty.
Parameters:
application the application which must be started
arguments the arguments with which the application will be started
local if tgyenox.yes then the application will be started on the
local machine, otherwise it will be started on the server.
Note that only on BW the tgyenox.yes should be used, in which
case a: "create.object(DsCapplication, 0, ...)" will be done.
In all other cases either a "shell()" or "run.prog()" will be
done depending on the current Baan version.
This function does NOT check whether the current platform is BW.
mode the mode needed for "shell()" or "run.prog()"
pop_up whether (if true) or not (if false) pop-ups on errors must be
given. Default is: false.
Return value:
= 0 successful completion, application started
< 0 some error occurred
-------------------------------------------------------------------------------
ENDDLLUSAGE
Nancy Mathew
16th July 2004, 18:16
I did the following :
Created a Session with a 3GL Script attached. This script invokes a shell script which checks the number of bshells if the number of bshell exceeds quota for user outputs a flag to a file and return to session, the session reads the file and if the flag is set invoke another script to kill bshell. Code shown below. This is also giving same result - runs through menu browser fails to invoke through DEM. Even tried with full authorization to DEM user. Any thoughts?
declaration:
long file_id, proc_pid
string return_field, tmp(8), comd(56)
|****************************** PROGRAM SECTION ***************************
function main()
{
e= shell "${BSE}/scripts/check_script.ksh",SHELL_BACKGROUND+ SHELL_NO_WAIT)
suspend(300)
file_id = seq.open("${HOME}/returnval", "r")
if file_id >= 0 then
return_field = ""
e = seq.read(return_field,1,file_id)
e = seq.close(file_id)
if return_field = "1" then
proc_pid = bshell.pid()
tmp = str$(proc_pid)
mess("tdsls9301.1",1)
comd = "${BSE}/scripts/kill_script.ksh" & tmp
shell(comd,SHELL_BACKGROUND + SHELL_NO_WAIT)
endif
endif
}
NPRao
16th July 2004, 22:50
I read the thread. We have a similiar requirement.
We need to enable password aging in UNIX. so Baan users to change as and when it expires. How we can do it?
Please write an overview of how it can be achieved?
Sorry Eric, I think I didnt noticed your Q.
Refer to the BaaN support site for more info-
How to activate password aging for UNIX using the Baan GUI ?
Author R van Hensbergen Creation Date: 14 Nov 2001 Alternate ID:
Solution No: 119781 Last Modified: 24 Mar 2003 Status: Published
Product: tt7.1a Sub Product: Session: ttstppwdaging
Package: tt Version: B50 Release: c
Solution Type: KR:Question
I have enabled password aging on our HP-UX systems as part of Sarbines Oxley requirements and found couple of issues. BaaN has fixed the bugs and is releasing them in 7.3.a07 porting set for our BaaN version.
Please check with them for the relative porting set solutions for your BaaN Version.
Nancy,
Please post your shell scripts. Only root login is allowed to kill users or unless you have setup all the sudo access for the file.
I am wondering why are you using a BaaN option to kill the user and the script has to be automatically execute when a user is logging in and you shouldnt expect the user to be executing it.
There are many threads on the board which discuss about the shell scripts/licence issues to auto-kill/disable user logins.
Also, refer to the FAQ to use the code tags.