Cannot get <EXEC> to do anything

Post Reply
barry.marcus
Posts: 288
Joined: Thu Nov 16, 2006 1:05 pm

Cannot get <EXEC> to do anything

Post by barry.marcus »

I am completely stumped, and frustrated, with trying to do something that is outwardly simple, and yet does not seem to work, no matter what I try. I will admit that this may not be a Vortex issue, but since I am trying to do this *from* my Vortex script I thought I'd pick your brain...

I want to use Vortex <EXEC> to synchronously (i.e., EXEC and wait for the call to return before proceeding) run Microsoft Access, passing the name of a database and a command line to Access. The code embedded in the Access database runs, reads the command line (which, by the way, is the path of a simple text file built by the Vortex script which in turn contains a comma-delimited string of data), opens the text file, reads the comma-delimited string of data contained therein, does stuff with the data, then quits, passing control back to the Vortex script which continues. Simple enough. But it does not seem to work. The Access code works fine. I have tested it many many times. The Vortex script correctly builds the text file. But the <EXEC> does not start Access and I cannot figure out why.

The path to Access is:
C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE

The path to the database is:
D:\Crosshairs\external\My Database With Code.accdb

The command line is:
D:\Windows\TEMP\CMD_577df59c3.txt

To pass a command line to Access, from a command prompt, the syntax is:
MSAccess.exe <databasename> /cmd <commandline>

I realize there are spaces in the paths, and have tried every combination I can think of of using NOQUOTEARGS vs. QUOTEARGS, using quotes to surround the various parameters on the <EXEC> line, using STDERRTOFILE, using -- before the start of the command, etc. Nothing seems to work.

Shouldn't the following work, and if not, why?

<exec stderrtofile="D:\Crosshairs\accesscallerr.txt" noquoteargs -- "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "D:\Crosshairs\external\My Database With Code.accdb" /cmd "D:\Windows\TEMP\CMD_577df59c3.txt"></exec>

This seems to do nothing at all. Moreover, the file D:\Crosshairs\accesscallerr.txt is empty, and the value of $ret returned by <EXEC> is also empty.

Ideally, I'd write each of the paths to a variable so the code looks a little neater. Also, ideally, I'd like to put the call to the Access EXE in a batch file and use

cmd.exe /c TheBatchFile.bat

to call that instead of calling Access directly.

(The reason for this is that Access is not installed in the same directory on every server where we run the Vortex script. As it is now, the Vortex script on each server will have to be "customized" for that server's Access installation. This was the first thing I attempted, but when that didn't work I simplified things -- or so I thought -- calling Access directly.)

Again, I realize that this is *possibly* not a Vortex issue at all. But if the <EXEC> stament in my Vortex script is incorrect, maybe it IS a Vortex issue.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Cannot get <EXEC> to do anything

Post by mark »

Check the vortex.log to see if anything's logged there.

Are you running this vortex script directly from the command line or via a web server? If the latter it may not have access to the desired executables or other resources.

I'd try your simplified command line with the bat file and no spaces in names, esp. since that's what you want to do anyhow.
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

Cannot get <EXEC> to do anything

Post by Kai »

Generally you'd want QUOTEARGS (the default), especially since your paths have spaces. But changing to that didn't work for me either.

Try using cmd.exe to run Access:

<exec stderrtofile="D:\Crosshairs\accesscallerr.txt" noquoteargs --
"cmd.exe" "/c" '"C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" D:\PathWithNoSpaces\YourDatabase.accdb /cmd D:\AnotherPathWithNoSpaces\Temp\foo.txt'
>
</exec>

Note the quoting scheme: double-quotes around `cmd.exe', `/c' and the path to MSACCESS.EXE; then single quotes around the entire Access command line. And no quotes around the *args* to Access: cmd.exe doesn't seem to like more than one set of double quotes (or at least didn't in my experiments). This means you'll need space-free paths to your Access database and Access command file.
Post Reply