EXEC command to call .bat file not working

Post Reply
steve.meeks
Posts: 3
Joined: Fri May 01, 2009 11:30 am

EXEC command to call .bat file not working

Post by steve.meeks »

I'm trying to use the EXEC command to call a .bat file. The .bat file runs simple dos commands to add a table to one of the directories the program uses.

I'm calling the command inside a file using the vortex language.

Here's a snippet of my code:

<script language=vortex>
<db=c:\MORPH3\Texis\directory_1s\>
<TIMEOUT = -1>
timed out
</TIMEOUT>


<a name=main PUBLIC>


<EXEC C:\morph3\texis\scripts\test_add_table.bat></EXEC>


</a>

</script>



Here's the contents of the .bat file:

cd C:
cd MORPH3
cd Texis
cd directory_1s
PAUSE
c:\morph3\addtable items_all.tbl
PAUSE
cd ..
cd directory_2s
c:\morph3\addtable items_all.tbl
PAUSE
cd ..
cd ..
ECHO "Made it here"
PAUSE

-----
The table items_all.tbl is a custom table that is dropped every time by the vortex script because truncating it was not resizing the table. This caused it to become very large and eventually vortex.log filled up.

My question is -- am I using the <EXEC> command incorrectly? Why will it not call the .bat file and run the simple dos commands from the DOS prompt?

Any help is appreciated.

Thanks.
User avatar
John
Site Admin
Posts: 2597
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

EXEC command to call .bat file not working

Post by John »

To exec a .bat file you need to exec cmd.exe with the batch file as an argument, as a batch file is not executable as is, e.g.

<exec cmd.exe /c C:\morph3\texis\scripts\test_add_table.bat></exec>

although you could just exec the addtables yourself, e.g.

<exec CHDIR="c:\morph3\texis\directory_1s" c:\morph3\addtable items_all.tbl>
<exec CHDIR="c:\morph3\texis\directory_2s" c:\morph3\addtable items_all.tbl>

or use <SQL "CREATE TABLE"> after dropping the table.
John Turnbull
Thunderstone Software
steve.meeks
Posts: 3
Joined: Fri May 01, 2009 11:30 am

EXEC command to call .bat file not working

Post by steve.meeks »

Thanks. I went with the 2nd option as that's easier to include all the code in the same file with the vortex code.

I am getting an error "command: c:\morph3\addtable returned exit code 1". What does this mean?
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

EXEC command to call .bat file not working

Post by mark »

It means that the addtable command exited with a status code of "1" instead of the normal "0". Look at $ret and $ret.stderr to see if any problems were reported.
Post Reply