Home » Developer & Programmer » Forms » How to execute a bat file from client machine? (forms migration from 6i to 10g)
How to execute a bat file from client machine? [message #398946] Mon, 20 April 2009 00:00 Go to next message
sirivijay
Messages: 48
Registered: October 2008
Member
Hi,
When migrating forms from 6i to 10g.I had an issue that i need to run a bat file (REPORT.BAT)containing the following text " START IEXPLORE C:\Apps\Client\LSTRANS.xml"This will invoke the browser and show the report.

In 6i this is coded as host(batfile)..How i can implement this in 10g.this is working in local machine when developing.but its not working after i deployed to the serevr.tried attaching webutil and used client_host(batfile) it doesnt worked.any other solution??
Re: How to execute a bat file from client machine? [message #398948 is a reply to message #398946] Mon, 20 April 2009 00:10 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
6i is client/server
So "host" command invoke a client side utilty.
10g is web based.
So "host" command invoke utility on the Application Server.

You need to resolve the differences.
Re: How to execute a bat file from client machine? [message #398950 is a reply to message #398946] Mon, 20 April 2009 00:17 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, you might research use of the CLIENT_HOST. Perhaps it'll do some good.
Re: How to execute a bat file from client machine? [message #398955 is a reply to message #398950] Mon, 20 April 2009 00:27 Go to previous messageGo to next message
sirivijay
Messages: 48
Registered: October 2008
Member
Thanks for your reply littlefoot.I tried using client_host..When tracing when the control goes to the procedure of client_host of webutill, it is breaking in the middle and going to the exception. i am passing the file containing the exact path of bat file.i feel the code is clear and not knowing what breaks the client_host as it is getting the required path of batfile the bat file is running and showing the report in internet explorer when i click it manually from that location.

Is there any other logic i can use to make this report displayed.i mean other than batfile..
Re: How to execute a bat file from client machine? [message #399121 is a reply to message #398955] Mon, 20 April 2009 14:58 Go to previous messageGo to next message
mudabbir
Messages: 235
Registered: April 2006
Location: Kuwait
Senior Member

Please post your code here. It will help us better..

Mudabbir
Re: How to execute a bat file from client machine? [message #399194 is a reply to message #398946] Tue, 21 April 2009 01:40 Go to previous messageGo to next message
sirivijay
Messages: 48
Registered: October 2008
Member
PROCEDURE START_IEXPLORER (fileName VARCHAR2)
IS
hFile CLIENT_TEXT_IO.FILE_TYPE;
V_METHOD_NAME CONSTANT VARCHAR(40) := 'PROCEDURE START_IEXPLORER';
V_METHOD_LABEL VARCHAR(40);
v_temp_dir VARCHAR(100) := 'c:\Apps';
v_cmd_file_loc VARCHAR(200);
serverxml VARCHAR(200) ;
serverxsl VARCHAR(200) ;
serverbat VARCHAR(200) ;
clientxml VARCHAR(200) ;
clientxsl VARCHAR(200) ;
clientbat VARCHAR(200) ;
BEGIN
serverxml := 'C:\Apps\LSTRANS.xml';
serverxsl := 'C:\Apps\LSTRANS.xsl';
--serverbat := 'C:\Apps\EgisReport.bat';
clientxml := 'C:\Apps\Client\LSTRANS.xml';
clientxsl := 'C:\Apps\Client\LSTRANS.xsl';
clientbat := 'C:\Apps\Client\EgisReport.bat';
--WEBUTIL_FILE_TRANSFER.AS_TO_CLIENT_WITH_PROGRESS(clientxml,serverxml,'Downloading the XML file if exist','please wait');
--WEBUTIL_FILE_TRANSFER.AS_TO_CLIENT_WITH_PROGRESS(clientxsl,serverxsl,'Downloading the XSL file if exist','please wait');
IF WEBUTIL_FILE_TRANSFER.AS_TO_CLIENT_WITH_PROGRESS(clientxml,serverxml,'Downloading the XML file','please wait') Then
Message('XML file Transferred to client', NO_ACKNOWLEDGE);SYNCHRONIZE;
else
Message('XML file not Transferred', NO_ACKNOWLEDGE);SYNCHRONIZE;
end if;

IF WEBUTIL_FILE_TRANSFER.AS_TO_CLIENT_WITH_PROGRESS(clientxsl,serverxsl,'Downloading the XsL file','please wait') Then
Message('XsL file Transferred to client', NO_ACKNOWLEDGE);SYNCHRONIZE;
else
Message('XsL file not Transferred', NO_ACKNOWLEDGE);SYNCHRONIZE;

end if;

--Tool_Env.Getvar('TEMP', v_temp_dir);
/* Close file when already opened */
V_METHOD_LABEL := 'Close file';
CLIENT_TEXT_IO.FCLOSE(hFile);
V_METHOD_LABEL := 'Open file';
--v_cmd_file_loc := v_temp_dir || '/EgisReport.bat';
v_cmd_file_loc := clientbat;
hFile := CLIENT_TEXT_IO.FOPEN(v_cmd_file_loc, 'W');

CLIENT_TEXT_IO.PUT(hFile, 'START IEXPLORE ' || clientxml);

CLIENT_TEXT_IO.FCLOSE(hFile);

CLIENT_HOST(v_cmd_file_loc);
EXCEPTION
WHEN OTHERS THEN
MESSAGE(DBMS_ERROR_TEXT || V_METHOD_NAME || V_METHOD_LABEL);
END;
icon14.gif  Re: How to execute a bat file from client machine? [message #399770 is a reply to message #398946] Thu, 23 April 2009 23:14 Go to previous messageGo to next message
sirivijay
Messages: 48
Registered: October 2008
Member
I Solved this issue..


But not as desired.I ignored the action of executing a bat file.

As the batfile is just trying to call the file with the help of internet explorer.I ignored creating batfile and changed the code as i mentioned below..which worked.

CLIENT_HOST('cmd /c START IEXPLORE C:\Apps\Client\LSTRANS.xml');


Still did not know why client_host fails to execute the .bat file
Re: How to execute a bat file from client machine? [message #400068 is a reply to message #399770] Sat, 25 April 2009 12:12 Go to previous messageGo to next message
mudabbir
Messages: 235
Registered: April 2006
Location: Kuwait
Senior Member

I tried using this command to open a PDF file without calling Adobe. and it worked. I presume it should work for BATch files too.

CLIENT_HOST('cmd /c rundll32 url.dll,FileProtocolHandler C:\test.bat');


Mudabbir
Re: How to execute a bat file from client machine? [message #400377 is a reply to message #398946] Mon, 27 April 2009 23:37 Go to previous messageGo to next message
sirivijay
Messages: 48
Registered: October 2008
Member
The code you gave is working if i run it from the start->run command but when i am placing this in client_host its not working..i think some thing is stopping to execute the bat file.in my machine.

can you give me an idea.

i want to create some files in temporary folder of the server and transfer them back to client and open them as a report in internet explorer.

in 6i this is implemented by taking the temp folder path from environment,creating the files there..and opening in the browser with the bat file.


in 10g i created a folder temp in folder where all my forms are placed,then creating the files there,bringing them to client's c:\(as common to every client) drive and opening it..

I completely hardcoded every path in the code but i guess its a bad implementation..

as this is a development server..i need to change the code to implement in production.as i have to create a temp folder there and give client and server path in code again

any idea how i can make this independent of hardcoading..






Re: How to execute a bat file from client machine? [message #400502 is a reply to message #400377] Tue, 28 April 2009 08:51 Go to previous messageGo to next message
mudabbir
Messages: 235
Registered: April 2006
Location: Kuwait
Senior Member

Quote:
in 10g i created a folder temp in folder where all my forms are placed,then creating the files there,bringing them to client's c:\(as common to every client) drive and opening it..

I completely hardcoded every path in the code but i guess its a bad implementation..

as this is a development server..i need to change the code to implement in production.as i have to create a temp folder there and give client and server path in code again


" Creating the files there... " how are you doing that?

let me tell u what i have done.... i have a table in my database where i have a column of type CLOB where i am actually storing a PDF file. this is the code i used to download the file on to client machine and open it on client machine..

PROCEDURE DOWNLOAD_DB IS
  l_success boolean;
  var varchar2(500);
  al_id Alert;
  al_button NUMBER; 
BEGIN
  l_success := webutil_file_transfer.DB_To_Client
                                    (clientFile      => 'C:\temp\tmp.pdf'
                                    ,tableName       => 'emp'
                                    ,columnName      => 'ACTUAL_FILE' 
                                    ,whereClause     => '');
    if l_success then
  		var := 'cmd /c rundll32 url.dll,FileProtocolHandler C:\temp\tmp.pdf';
			IF copy_by_host_cmd(var) then 
				al_id := Find_Alert('User_Warning');
				al_button := Show_Alert(al_id);  
				IF al_button = ALERT_BUTTON1 THEN
					var := 'cmd /c Del c:\temp\tmp.pdf';
					IF copy_by_host_cmd(var) then 
						null;
					end if;
				end if;
  		Else
  			Display_okay_message1('Acrobat Reader may not be installed on your Computer. Please contact Administrator');
  		end if;
  else
    display_okay_message1('File download from Database failed');
  end if;
END;



FUNCTION copy_by_host_cmd(VAL varchar2)
RETURN BOOLEAN IS
BEGIN
	client_host(val);
	return TRUE;

EXCEPTION 
	WHEN OTHERS THEN
	return FALSE;
END;


Let me know if u didnt understand anything
Mudabbir
Re: How to execute a bat file from client machine? [message #401320 is a reply to message #400502] Mon, 04 May 2009 01:21 Go to previous message
sirivijay
Messages: 48
Registered: October 2008
Member
Hi Mudabbir,
Thanks for the reply..If you see my code below you will get a clear picture of my requirement.

You can observe that i have hard coded some paths of server.As this is a development server code may not work when moved to the production.if i code like this it will not be accepted as the code is not portable..

the code you mentioned is having the hardcoded client path ..as the client may have some common folder it may not create the problem.but as the server is considered ,the deployment folders keeps varrying...so can you please suggest me how i can make the code independent up to forms path..as i can create the temporarily folders inside the application folder in server's forms path and make it portable.



PROCEDURE START_IEXPLORER (fileName VARCHAR2)
IS
  hFile           CLIENT_TEXT_IO.FILE_TYPE;
  V_METHOD_NAME   CONSTANT VARCHAR(40) := 'PROCEDURE START_IEXPLORER';
  V_METHOD_LABEL  VARCHAR(40);
  v_temp_dir      VARCHAR(100) := 'e:\APPS\oracle\as10g_mid\forms\EGIS\temp';
  v_cmd_file_loc  VARCHAR(200);
  serverxml VARCHAR(200) ;
  serverxsl VARCHAR(200) ;
  serverbat VARCHAR(200) ;
  clientxml VARCHAR(200) ;
  clientxsl VARCHAR(200) ;
  clientbat VARCHAR(200) ;
BEGIN
	serverxml := 'e:\APPS\oracle\as10g_mid\forms\EGIS\temp\LSTRANS.xml'; serverxsl := 'e:\APPS\oracle\as10g_mid\forms\EGIS\temp\LSTRANS.xsl';

  clientxml := 'C:\Apps\LSTRANS.xml';
  clientxsl := 'C:\Apps\LSTRANS.xsl';
  
    IF WEBUTIL_FILE_TRANSFER.AS_TO_CLIENT_WITH_PROGRESS(clientxml,serverxml,'Downloading the XML file','please wait') Then
   	  Message('XML file Transferred to client', NO_ACKNOWLEDGE);SYNCHRONIZE;	
  else
  	Message('XML file not Transferred', NO_ACKNOWLEDGE);SYNCHRONIZE;
  	end if;
  	
  	IF WEBUTIL_FILE_TRANSFER.AS_TO_CLIENT_WITH_PROGRESS(clientxsl,serverxsl,'Downloading the XsL file','please wait') Then
   	  Message('XsL file Transferred to client', NO_ACKNOWLEDGE);SYNCHRONIZE;	
  else
  	Message('XsL file not Transferred', NO_ACKNOWLEDGE);SYNCHRONIZE;
  	
  	end if;
  
  
   CLIENT_HOST('cmd /c START IEXPLORE C:\Apps\LSTRANS.xml');
Previous Topic: 'Do you want to save the changes you have made?" suppression
Next Topic: Disable & Enable Push Button Trough Trigger
Goto Forum:
  


Current Time: Fri Sep 20 10:28:27 CDT 2024