Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / May 2005

Tip: Looking for answers? Try searching our database.

Create txt file from DOS session

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil F - 28 May 2005 22:03 GMT
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
John Nurick - 29 May 2005 07:48 GMT
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.

>Hi -
>
[quoted text clipped - 22 lines]
>Many thanks in advance,
>Phil Freihofner, Albany CA

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.