Create txt file from DOS session

G

Guest

Hi -

Currently, Users hit a button on a website, initiating a Command Prompt
session with a legacy database that prompts for User name and password before
allowing the User to run a report. We want to automate the transfer of the
report output to Access.

I'm assuming I can use the Shell function to invoke the legacy database, and
pass over control to the User (from within Access). But I am wondering if
there is a way to have the session automatically be saved into a text file
which I can parse later to get the data we need.

My DOS is quite rusty. Isn't there some sort of "pipe" function or
something? I've tried the following but no new file gets saved:

dim varAA as variant
varAA = shell(c:\temp\helloworld.exe > c:\temp\hello.txt, vbNormalFocus)

Here, the simple "helloworld.exe" just sends "hello world" to the
CommandPrompt console. User types "Exit" and is back in Access.

The owners of the legacy database are adamant about not allowing any sort of
ADO or ODBC connections being set up to the database itself.

Many thanks in advance,
Phil Freihofner, Albany CA
 
J

John Nurick

Hi Phil,

There are several possible issues here. The first, of course, is that if
you're passing a literal string to Shell() you have to quote it, and
also quote any paths in the command that might contain spaces, e.g.

varAA = Shell("""C:\temp\Hello World.exe"" > ""C:\temp\hello.txt""")

I guess you're doing this but forgot to include the quotes in the
example you posted.

Normally one can ignore the return value, and therefore omit the
assignment. Also, it's often necessary to explicitly invoke the command
interpreter, with the /c switch to make it close after executing the
command, e.g.

Shell "cmd.exe /c ""C:\temp\Hello World.exe"" > ""C:\temp\hello.txt"""

The next thing is that by no means all DOS programs deliver their output
(either on-screen or printed) to the standard console or print devices
and therefore in a form that can be redirected. Virtually all serious
DOS applications address the screen directly (so they can run as
full-screen applications) and use their own printer drivers. Even your
helloworld.exe may not use the standard output.

So the real question is, can the legacy app be controlled from the DOS
prompt and made to write the report to a file? If so, you can put the
same commands into a .CMD file and use Shell("cmd.exe /c ...") to
execute it. If not, I think you're stuck.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top