Execute a batch file with the Shell Macro command?

Have a suggestion for improving DPlot or a question about existing features? Let us know

Moderator: DPlotAdmin

Post Reply
russurquhart1
Posts: 14
Joined: Wed Nov 18, 2009 2:32 pm

Execute a batch file with the Shell Macro command?

Post by russurquhart1 »

Hi,

I am trying to run a batch file (.bat) that has two arguments, from within a macro.

I was trying something like

Shell("run.bat file1 file2", "4")

but it doesn't seem to work. Can anyone help?

Any help is greatly appreciated!

Thanks,


Russ
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Get rid of the quotation marks around the "4". You also may need to specify the full path to the batch file.
Visualize Your Data
support@dplot.com
russurquhart1
Posts: 14
Joined: Wed Nov 18, 2009 2:32 pm

Post by russurquhart1 »

I'm still having a little problem.The full pathname to the bat file is:

Shell("C:\Program Files\gs\gs8.64\lib\rups2epsi.bat C:\testout.ps C:\testout.eps", 3)

It doesn't seem to be executing. I think it's getting stuck on Program Files, thinking those are two words. I tried putting single quotes around that, but that didn't work.

Any ideas?

Thanks,


Russ
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

My mistake. The macro handler is doing a poor job of parsing things, and your commandline arguments aren't being handled. The problem has nothing to do with the space in the path, so moving the batch file won't help. I'll fix this as soon as possible. Sorry for the trouble.
Visualize Your Data
support@dplot.com
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Whoops, I'm wrong again. The problem IS the spaces in the path. If you move the batch file to a folder whose name doesn't contain spaces it should work.

The solution would seem to be something like

Shell(""C:\Program Files\gs\gs8.64\lib\rups2epsi.bat" C:\testout.ps C:\testout.eps", 3)

but that won't work, as the macro handler will interpret that second quotation mark as the end of the command. Again, will fix this right away.
Visualize Your Data
support@dplot.com
russurquhart1
Posts: 14
Joined: Wed Nov 18, 2009 2:32 pm

Post by russurquhart1 »

Thanks for you attention on this.

I had been working on a workaround, but had ran into another issue that, since you're looking at this, is an interesting anomaly.

In this bat file, an alternation of ps2epsi.bat that comes with ghostscript, in the middle of the bat file is the following line:

rem Append the original onto the preview header
copy %outfile% + %infile%

Processing happens before and after this line.

When I WAS able to get the bat file to kind of run, via the Shell macro command, THIS line would never get executed. The lines before and after did, but not this line. If i ran the bat outside a command window, it worked.

It's no biggie, i changed the line to

copy %outfile% + %infile% %outfile%

and that seems to work, but i thought you might like to know! Kind of strange.

Thanks,

Russ
jsc
Posts: 222
Joined: Fri Dec 02, 2005 8:56 am

Post by jsc »

Would using short names, ie, the 8.3 dos name equivalents, help?
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

No idea, sorry. Once whatever process you're shelling out to takes over, DPlot and dpmac.exe really have nothing to do with it. My initial guess would be that there's something odd going on with the environment strings, like the batch file inherits dpmac.exe's environment settings and either %outfile% or %infile% or both aren't defined. But that can't be right, else your solution would not have worked.
Visualize Your Data
support@dplot.com
Post Reply