tusharjain2204
29th October 2013, 11:35
Hello everyone,
I'm trying to execute a batch file on the server and I've tried the following command to do so:
ret = run.prog(pdf.out&".bat", "", RP_WAIT, "", "", "")
or
ret = run.prog("cmd.exe", "/" & pdf.out&".bat" , RP_WAIT)
where, pdf.out is the path of my temporary file.
It returns 0, that is successful, but I don't see the output.
However, if i run the same bat file manually by logging on to the server, it gives proper output.
Please help me with this.
Thanks in advance.
Regards,
Tushar.
Han Brinkman
29th October 2013, 12:29
This is standard behaviour. Remember your bshell is running on the server, not local on your desktop. So the run.prog is executed on the server.....
You probably want to use the functions server2client() to transfer the file to your desktop and app_start() to start the application.
Have a look at the programmers guide to find more details.
bhushanchanda
29th October 2013, 12:33
Hi,
What is into the bat file? Check if it needs administrator permissions to run.
The command works for me:-
run.prog("D:\temp\test_bat.bat","",RP_NOWAIT)
Also, check the permissions on the file, BSP or Baan user should have full rights on the file.
What you can do is, you can send you file to the server using client2server and then execute it using run.prog().
tusharjain2204
29th October 2013, 12:48
Hi,
What is into the bat file? Check if it needs administrator permissions to run.
The command works for me:-
run.prog("D:\temp\test_bat.bat","",RP_NOWAIT)
Also, check the permissions on the file, BSP or Baan user should have full rights on the file.
What you can do is, you can send you file to the server using client2server and then execute it using run.prog().
Bhushan,
In the bat file I'm inserting the following command:
line = quoted.string("c:\Program Files\gs\gs9.07\bin\gswin64c.exe") & " -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="&tmp.file&".PDF -f "&tmp.file&".ps"
That is, I'm using ghostscript to convert any report output to pdf.
I've even checked the permissions.
I'm using the baan login.
When I run the bat file manually through Remote Desktop by logging on to the server using the baan login, i get the pdf file as output.
bhushanchanda
29th October 2013, 13:12
Hi,
Is the application installed on the server machine?
If yes, what you can do is, you just create a bat file on the server using seq.* functions at run time and close it. Now, go to server and check if it runs as expected.
Sometimes, the blank spaces or characters can cause problems in the bat file execution.
Also, try to use
ret = run.prog("D:\new\test.bat","",RP_NOWAIT,"","","D:\new\err.txt") to check if there is any errors while running the bat file.
tusharjain2204
29th October 2013, 14:09
Hi,
Is the application installed on the server machine?
If yes, what you can do is, you just create a bat file on the server using seq.* functions at run time and close it. Now, go to server and check if it runs as expected.
Sometimes, the blank spaces or characters can cause problems in the bat file execution.
Also, try to use
ret = run.prog("D:\new\test.bat","",RP_NOWAIT,"","","D:\new\err.txt") to check if there is any errors while running the bat file.
Hi Bhushan,
I tried that previously.
While the script was in debug mode, i kept going step by step until the step where the bat file was created. Then i let the script hang there, took rdc of the server and ran the bat file manually. It gave me the expected output.
Also, I took the error file as you suggested using the following command:
ret = run.prog(pdf.out&".bat", "", RP_WAIT, "", "stdout.txt", "stderr.txt")
stderr.txt contained this:
GPL Ghostscript 9.10: **** Could not open temporary file ''
stdout.txt contained this:
E:\Infor\ERPLN\bse\tmp>"c:\Program Files\gs\gs9.10\bin\gswin64c.exe" -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=E:\Infor\ERPLN\bse\tmp/tmp065090656.PDF -f E:\Infor\ERPLN\bse\tmp/tmp065090656.ps
GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
**** Unable to open the initial device, quitting.
bhushanchanda
29th October 2013, 14:17
Hi,
While in debugger, are you able to see the tmp file in the $bse\tmp folder?
Are you able to open it? I guess you are trying to convert a file while it is in use so the application is not able to open it. Check if you are closing the file to be converted before trying to convert it.
NPRao
30th October 2013, 02:17
ret = run.prog(pdf.out&".bat", "", RP_WAIT, "", "", "")
or
ret = run.prog("cmd.exe", "/" & pdf.out&".bat" , RP_WAIT)
Refer to the threads to use /c with cmd.exe
Running batch file on server (http://www.baanboard.com/baanboard/showthread.php?t=29134&highlight=batch+cmd)
Question run.prog will not work!! (http://www.baanboard.com/baanboard/showthread.php?t=28033&highlight=run.prog)
line = quoted.string("c:\Program Files\gs\gs9.07\bin\gswin64c.exe") & " -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="&tmp.file&".PDF -f "&tmp.file&".ps"
Instead of a single line command string, split it and send the various options as arguments in the run.prog() call.
tusharjain2204
30th December 2013, 13:40
Hello everyone,
Thank you guys for all the help.
The original problem is still the same. :P
Ghostscript is not getting triggered on our server.
So, instead of using Ghostscript to convert my report output to PDF, I'm trying to pass 'XML -PDF' as an argument to ttstpconv to convert it to PDF.
I noticed that when we create a PDF device using 'XML -PDF' argument, we also check 'Intermediate file in XML Format' option.
Can someone help me on how to pass this as an argument to ttstpconv in a 3GL script?
Regards,
Tushar.
bhushanchanda
30th December 2013, 14:00
Hi,
You can try this:-
XML -PDF:acroRd32.exe %s
tusharjain2204
30th December 2013, 15:26
Hi,
You can try this:-
XML -PDF:acroRd32.exe %s
Hi Bhushan,
I had removed the 'acroRd32.exe' part from the command because I don't want to launch Adobe Reader. Instead I want to use the resulting PDF file in my code further to super-impose it with a logo file.
So I tried to use this:
wait.and.activate("ttstpconv", argv$(1), tmp.file, "XML -PDF %s", argv$(4))
But I'm getting an error saying "Conversion to 'XML -PDF %s' is not supported yet".
Did i use it correctly??
Regards,
Tushar
bhushanchanda
31st December 2013, 11:02
Hi,
Try replacing with:-
XML -PDF: %s, but again, an intermediate XML needs to be generated so it will cause an error. I have never tried it.
I usually go for SSRS reports else, I create HTML file and while printing, you can convert HTML to PDF. You can use Chrome browser, it can save the html file as pdf. Else, you can add the logo in your baan report as well.
Else if you want, there are tools from Nazdaq to handle the reports.
tusharjain2204
31st December 2013, 13:41
Hi,
Try replacing with:-
XML -PDF: %s, but again, an intermediate XML needs to be generated so it will cause an error. I have never tried it.
I usually go for SSRS reports else, I create HTML file and while printing, you can convert HTML to PDF. You can use Chrome browser, it can save the html file as pdf. Else, you can add the logo in your baan report as well.
Else if you want, there are tools from Nazdaq to handle the reports.
Hi,
I looked up Inforxtreme to find if 'Intermediate file in XML Format' can be passed as an argument, and realized that it is not possible.
Instead, I searched for a portable version of Ghostscript. So currently, I'm copying all files on to the client and doing all operations there.
But I'll definitely try what you suggested.
Thanks for all the help. :)
Regards,
Tushar.