Skip to Main Content
  • Questions
  • Command Host unable to open document file

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Lorenzo.

Asked: October 06, 2000 - 2:38 pm UTC

Last updated: December 31, 2003 - 4:19 am UTC

Version: Forms(32 bit) version 5.0.6.8.0

Viewed 1000+ times

You Asked

Tom:

We were trying the opening of documents from a form with the command:
host(<string>);
beign <string> a string with the full name of the document (p.ej. 'c:\siesta\el_arte_de_dormir.doc')
It works on the MS-DOS shell if we start the sell from the 'Start' Menu of windows (Windows NT 4.0, by the way). The command we issue is
prompt><string>
(ej. prompt>c:\siesta\el_arte_de_dormir.doc )
and the doc. opens

But if we launch it from forms it says that does not understand the command.

Then we tried with the command start, issuing in our form:
host('start' || <string>);
beign <string> a string with the full name of the document (p.ej. host('start c:\siesta\el_arte_de_dormir.doc')

And, the same, forms open a DOS window that complains, quickly dissappears and the document does not get opened. If we open the DOS window from Start menu of Windows and issue the command it works OK.

As last resource, we created a MS-DOS batch program (*.bat) that accepted the document name as parameter. The batch only issued 'start <string>' (being <string> the doc name). And with a little plumbing to handle the case in which the parameter passed had blanks inside (like filename 'This documento.doc') it worked OK FROM FORMS with the instruction:

host('batch_file_Name ' || <string>);

As we did not like that, we pulled other resources and after no little research we could download a package and a dll from Oracle with the function START_DOCUMENT (or sth. like that) that worked OK.

But working that way has the drawback that in the instalation of the deliverable we must copy the dll in the directory [oracle]\bin. We also do not like that, as our customer has strict security measures in client PCs and we should try not to write in that directory, as usually is protected.

So, one solution implies a call to a batch program, which name should not be fully qualified (because the application is supposed to be able to be installed in any directory), and we should get into the annoyance of having a registry variable for that. Other way may be to construct at runtime the file in a known location, but it does not sound very well to me (messy or 'chapucero' as we say in Spain)

The other implies to install a downloaded dll into a possibly protected directory, so the installation get complicated (and although the dll is downloaded from Oracle, we should get it officially from the Oracle support of our customer, which is going to be another pain in the neck).

After so long preliminars the questions are:

1.- Is there any way to use the host command to launch the file without all those problems?

2.-Why do you think calling directly 'start' from the form (with 'host') did not work and calling 'start' through an intermediate
batch program worked?

Thank you.


and Tom said...

Try this command:

host( 'cmd /c "C:\Doc\Thomas Kyte\Desktop\todo.txt"',
NO_SCREEN );


The command processor goes through all kinds of hoops to start a program -- looking at the extension. We simply call "exec()" and if the OS won't run it - it won't run it. cmd.exe looks "harder" to find something to run and uses the associations of the extension to a program to build a real command to run.

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Huss

hussein, September 25, 2003 - 3:57 pm UTC

thankx tom
it helps me alot :)

How to run dos command under host

abdoul rahaman, December 31, 2003 - 4:19 am UTC

Really uncle tom is amazing man

Can we open a file in the remote server using host

B, October 28, 2008 - 1:47 am UTC

Hi Tom,

Can we open a file in a remote machine(mapped as F:\)
using host command. My requirement is I want to execute a batch file which will move files from client machine to the remote machine. I need to execute this batch file in Oracle reports. Reports is not recogonising host command.
Pls help me to sort out this problem.


More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library