Subscribe Bookmark RSS Feed

Can JMP call a DOS Exe

by dos exe I just mean a standard windows/dos command line app that would run in a xp command window.
After a quick google search I couldn't find anything for you. I don't remember seeing anything like that in the scripting guide either. What are you trying to do, maybe there's more than one way to do it.
If you also have SAS, you can write a JSL script that connects to SAS and then you can run DOS commands using the X command.

1) Connect to SAS using File->SAS->Server Connections
2) Write a JSL script:

conn = CurrentSASConnection();

code = EvalInsert(
X '"C:\Program Files\Microsoft\Office12\EXCEL.EXE"'

SAS Submit(code);

That would open up Excel using a DOS command through running SAS in the background.

Community Trekker


Jun 23, 2011

Just found this out today. The "web" command can run command line items:

I just tried it with a perl script and it worked, too.

Super User


Jun 23, 2011

Great find! I tried with an Applescript app and it worked perfectly. That opens up a range of possibilities.

However, the path must be in URL-style, like web("file:///Applications/JMPtest.scpt"), at least on the Mac.

Community Trekker


Jun 23, 2011

On Windows I actually entered the directory like: web("c:\blah\blah.exe"). Not sure if it makes a difference, but I'm using JMP 8.

Super User


Jun 23, 2011

I am also using JMP 8. Probably an OS thing, reflecting differences in how paths can be entered in a browser.
Actually, a more direct way to call any .exe file is via the Open("/path/to/my/app.exe") statement. Normally JMP expects a JMP, .txt, or .xls Excel file to open up within JMP. But if it encounters a unrecognized file type in the Open() statement (such as .bat, .exe, or .gif) then it defers execution to the operating system using default file type associations.

For example, if you specify a path to your .gif or .bmp image file, the image will be opened up (externally of JMP) using your default image viewer. A .bat file will be executed from a DOS shell (you will probably see a quick flash and disappearance of the black DOS shell window).

So you can write a .bat file to execute any DOS command, and call the .bat file from your JSL script.

Community Trekker


Jan 23, 2012

as deeper info to anyone interested:

it works, but in this way you can't pass parameters to the bat file.

Also it seems to execute it in a directory that could be different from the one in which the script is: I had some strange behaviour, but I had cmd.exe open and I didn't pursue it further since I changed my approach, maybe it was only a glitch or my fault.

anyway, if for someone these are issues (like for me) i recommend to create and execute the bat file from inside the jsl:

riga1 = "@echo off";

riga2 = "\!Ncd C:\Users\JRR\Documents\sandbox\v2.2_bat";

riga3 = "\!Ndir>urano.txt";

Save Text File(    "test_batch_write_file_selfmade.bat", riga1, mode ("replace"));

Save Text File(    "test_batch_write_file_selfmade.bat", riga2, mode ("append"));

Save Text File(    "test_batch_write_file_selfmade.bat", riga3, mode ("append"));

open ("test_batch_write_file_selfmade.bat")

in this way you can create a hardwired bat file using variables from jmp, and be sure on where it will be executed


Community Trekker


Mar 6, 2013

I would also like to point out the use of \!N in dghidoni's example.


SaveTextFile( "C:\Temp\cmddir.bat", "echo \!"directory list\!"\!N


pause\!N", mode("replace")) ;


SaveTextFile( "C:\Temp\cmddir.bat", "echo \!"directory list\!"


pause", mode("replace")) ;

The first one (with \!N) works, the second one doesn't. Your text editor may not display the difference. But if you run cmd.exe and then type:

cd c:\temp

type cmddir.bat

you will see the difference.