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
Execute a batch file with the Shell Macro command?
Moderator: DPlotAdmin
-
- Posts: 14
- Joined: Wed Nov 18, 2009 2:32 pm
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
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
support@dplot.com
-
- Posts: 14
- Joined: Wed Nov 18, 2009 2:32 pm
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
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
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
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
support@dplot.com
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
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.
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
support@dplot.com
-
- Posts: 14
- Joined: Wed Nov 18, 2009 2:32 pm
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
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
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
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
support@dplot.com