marwest98
30th July 2008, 20:19
I am trying to run a .exe to convert files.
Here is what I want to do, but I cannot seem to get it to work in the script itself:

long run.prog( const string progname, const string arguments, long mode, [ string stdin, string stdout, string stderr ])

Currently it looks like:
stdin="c:\scf\export\web\paymentadvise\checkfile&dat&"
stdout="c:\scf\export\web\paymentadvise\checkfilenew&dat&"
ret=run.prog("c:\scf\export\web\paymentadvise\CheckConversion.exe" long mode[stdin stdout])
suspend(5000)

I have also tried:
ret=run.prog("c:\scf\export\web\paymentadvise\CheckConversion.exe" rp_wait long mode[stdin stdout])

and
ret=run.prog("c:\scf\export\web\paymentadvise\CheckConversion.exe" rp_wait long mode ["c:\scf\export\web\paymentadvise\checkfile&dat&" "c:\scf\export\web\paymentadvise\checkfilenew&dat&"])

and
ret=run.prog("c:\scf\export\web\paymentadvise\CheckConversion.exe" rp_wait ["c:\scf\export\web\paymentadvise\checkfile&dat&" "c:\scf\export\web\paymentadvise\checkfilenew&dat&"])

and I have tried it without the rp_wait

There are no examples in the manual, so how is this supposed to be?

NPRao
30th July 2008, 21:14
run.prog() is a service side call.
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.
You have to use app_start (http://www.baanboard.com/programmers_manual_baanerp_help_functions_client_file_access_app_start) to use the client side (desktop) executables.

marwest98
30th July 2008, 21:44
What is meant by being distributed across different platforms? The .exe is on the server not on the client side. Several users will be running this, so it must be on the server.

NPRao
30th July 2008, 21:56
What is meant by being distributed across different platforms?
The programmer's guide has the info-
const string 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.

You can be invoking a shell script which can be connections via ssh/rsh/ftp or any other command to another system which can be on same or different OS.

I noticed your other posting - How do I execute a VBScript from within Baan (http://www.baanboard.com/baanboard/showthread.php?t=53174)
It is not clear which Operating System is your Baan Server running on etc. Please be explicit in posting your server setup information as others have no visibility to it and are trying to help you out.
stdin="c:\scf\export\web\paymentadvise\checkfile&dat&"
stdout="c:\scf\export\web\paymentadvise\checkfilenew&dat&"
Using & in file name seems non-standard to me. In Unix the & is also treated as background process to the shell commands.
Run your program in debug mode and find the return values and set a file to capture the information from stderr.

marwest98
31st July 2008, 01:15
I have not been able to get the script to compile because I can't get the syntax right on the run.prog.

The unix script was doing:
shell("cd :\scf\export\web\paymentadvise;.\advise;mv "&spool.fileout&" c:\scf\export\web\paymentadvise\archive\checkfile"&dat&" ",1 )

For the run.prog I need to run this executable which was a vbscript and I converted it into an exe.
"c:\scf\export\web\paymentadvise\BAANCheckConversion.exe"

The input file is: "c\scf\export\web\paymentadvise\checkfile&dat"
I need to put the current date at the end of the filename.
The output file needs to be:
"c\scf\export\web\paymentadvise\checkfilenew&dat"
with the date at the end of it too.

I'm trying to get them into the correct format to do the run.prog command:
long run.prog( const string progname, const string arguments, long mode, [ string stdin, string stdout, string stderr ]). No matter how I put the information in, it does not compile. I have tried it 20 different ways. There are no examples in the manual, so it is impossible to have something to compare it to or follow. We do not do anything like this in any other program. We have always used shell, since we were Unix.

Need help.

NPRao
31st July 2008, 08:49
The shell command is doing more than 1 steps and redundant steps. It should have been a multi-step copy with file.cp() and move with file.mv() etc or be converted into a batch script to run on Windows.
Anways we can improve it, try this code -


long ret
string ifile(256), ofile(256), errfile(256), execfile(256)

execfile = "C:\scf\export\web\paymentadvise\BAANCheckConversion.exe"
ifile = "C:\scf\export\web\paymentadvise\checkfile" & date$
ret = file.cp(spool.file, ifile)
ofile = "C:\scf\export\web\paymentadvise\checkfile_new" & date$
|* Predefined variable: string date$(6) R Current system date (DDMMYY).
|* Or use string dte$() - This returns the current date and time in the
|* format MMDDYYHHMMSS.
|* Or use sprintf$() with %D(format) - Use for dates.
errfile = "C:\scf\export\web\paymentadvise\checkfile_err" & date$
ret = run.prog("cmd.exe", "cmd /c " & execfile, RP_WAIT, ifile, ofile, errfile)

Try running the program in debugger and then find the return value as well as the output and error files.
I noticed you are using the predefined variable - spool.fileout - Is this program called with print spooler or report or device data?

Hopefully, this code works for you else we can see the error code and error message. Please post your results.

Few more threads for reference for the usage of run.prog() -
Running batch file on server (http://www.baanboard.com/baanboard/showthread.php?t=29134&highlight=run.prog)
Running .bat file from Baan Script (http://www.baanboard.com/baanboard/showthread.php?t=28144&highlight=run.prog)
run.prog will not work!! (http://www.baanboard.com/baanboard/showthread.php?t=28033&highlight=run.prog)

marwest98
31st July 2008, 14:17
Thank you for the information. I fixing the code right now. I was close at one point in time. Thank you also for the other threads, I did a search on run.prog, but I don't remember seeing those.

marwest98
31st July 2008, 15:44
I am getting a -1 on the ret=file.cp(spool.file, ifile) and a -1 on the ret=run.prog

marwest98
31st July 2008, 17:48
I got rid of the -1, but I am getting an err file now. This is the message

'c:\scf\export\web\paymentadvise\BAANCheckConversion.exe' is not recognized as an internal or external command,
operable program or batch file.

Still working on it.