<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I run multiple CMD commands? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/512290#M73981</link>
    <description>&lt;P&gt;Thank You All Many Times! PMROZ Your answer is exactly what I was looking for!&lt;/P&gt;&lt;P&gt;The last fault on my part is the space in the path which is easily solved with the&amp;nbsp;\!" character...&lt;/P&gt;&lt;P&gt;Solution:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;path1="C:/Users/niros/Downloads/";
path2="\!"C:/Program Files/WinRAR/WinRAR.exe\!"";
path3="C:/Users/niros/Downloads/LP.tgz";

//-------------------------------------------------------------------------------
// Create a command file to run multiple commands
cmd_file_text = evalinsert(
"rem Run multiple commands\!N
cd ^path1^\!N
mkdir testing\!N
cd testing\!N
^path2^ x ^path3^\!N
pause\!N
");
cmd_file_name = "c:\temp\run_commands.cmd";

// Save command file to disk
save text file(cmd_file_name, cmd_file_text, mode("replace"));

//-------------------------------------------------------------------------------
// The /c option carries out the command before terminating
run_cmds = runprogram(executable("cmd.exe"), options("/c " || cmd_file_name), readfunction("text"));

nw = new window("Output", &amp;lt;&amp;lt; modal,
	panel box("CMD output:",
		text box(run_cmds, set width(800), set wrap(800), 
				&amp;lt;&amp;lt; Set Font( "Courier New" )),
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Jun 2022 16:15:55 GMT</pubDate>
    <dc:creator>Niros</dc:creator>
    <dc:date>2022-06-22T16:15:55Z</dc:date>
    <item>
      <title>How do I run multiple CMD commands?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/511218#M73927</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do a simple extract of a zip file (TGZ) from JMP using the command prompt, and I don't manage to do it using the following approach (I tried many ridiculous ideas, none seem to work...):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

path1="C:/Users/niros/Downloads/";
path2="C:/Program Files/WinRAR/WinRAR.exe";
path3="C:/Users/niros/Downloads/LP.tgz";

RP = RunProgram(
	Executable( "CMD.EXE" ),
	Options( { {"cd", path1}, {"mkdir", "testing"}, {"cd", "testing"}, {path2,"x", path3} } ),
	Read Function("text")
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:01:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/511218#M73927</guid>
      <dc:creator>Niros</dc:creator>
      <dc:date>2023-06-09T17:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run multiple CMD commands?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/511320#M73932</link>
      <description>&lt;P&gt;Example 3 in the scripting index&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RunProgram set up to feed commands to CMD.exe" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/43409i4F5366CBED6C3A35/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="RunProgram set up to feed commands to CMD.exe" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;RunProgram set up to feed commands to CMD.exe&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;is one way.&lt;/P&gt;
&lt;P&gt;Another way would use a command separator within the parameters. Modified from example 1:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;RP = Run Program(
    Executable( "CMD.EXE"/*path probably not needed*/ ),
    Options( {"/a", "/q", "/c dir &amp;amp;&amp;amp; echo hello &amp;amp;&amp;amp; ping localhost"} ),
    ReadFunction( Function( {this}, Write( this &amp;lt;&amp;lt; read ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(Both of the above are set up to read from cmd.exe, as it runs, and write the answers to the JMP log. Your original example with readfunction("text") is the simpler, less flexible way that gathers all the output and presents it at the end.)&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 13:12:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/511320#M73932</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-06-21T13:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run multiple CMD commands?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/511629#M73941</link>
      <description>&lt;P&gt;You can also just write all of the commands to one CMD file and execute it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;path1="C:/Users/niros/Downloads/";
path2="C:/Program Files/WinRAR/WinRAR.exe";
path3="C:/Users/niros/Downloads/LP.tgz";

//-------------------------------------------------------------------------------
// Create a command file to run multiple commands
cmd_file_text = evalinsert(
"rem Run multiple commands\!N
C:\!N
cd ^path1^\!N
mkdir testing\!N
cd testing\!N
^path2^ x ^path3^\!N
pause\!N
");
cmd_file_name = "c:\temp\run_commands.cmd";

// Save command file to disk
save text file(cmd_file_name, cmd_file_text, mode("replace"));

//-------------------------------------------------------------------------------
// The /c option carries out the command before terminating
run_cmds = runprogram(executable("cmd.exe"), options("/c " || cmd_file_name), readfunction("text"));

nw = new window("Output", &amp;lt;&amp;lt; modal,
	panel box("CMD output:",
		text box(run_cmds, set width(800), set wrap(800), 
				&amp;lt;&amp;lt; Set Font( "Courier New" )),
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jun 2022 17:34:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/511629#M73941</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2022-06-21T17:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run multiple CMD commands?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/512035#M73965</link>
      <description>&lt;P&gt;For what it's worth, using RunProgram is tricky ... I suspect most of us have to try many ridiculous ideas before we get it to work :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 10:29:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/512035#M73965</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2022-06-22T10:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run multiple CMD commands?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/512120#M73967</link>
      <description>&lt;P&gt;I had to add hard returns to the .cmd file generated by JSL using "\!N".&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:45:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/512120#M73967</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2022-06-22T11:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run multiple CMD commands?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/512290#M73981</link>
      <description>&lt;P&gt;Thank You All Many Times! PMROZ Your answer is exactly what I was looking for!&lt;/P&gt;&lt;P&gt;The last fault on my part is the space in the path which is easily solved with the&amp;nbsp;\!" character...&lt;/P&gt;&lt;P&gt;Solution:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;path1="C:/Users/niros/Downloads/";
path2="\!"C:/Program Files/WinRAR/WinRAR.exe\!"";
path3="C:/Users/niros/Downloads/LP.tgz";

//-------------------------------------------------------------------------------
// Create a command file to run multiple commands
cmd_file_text = evalinsert(
"rem Run multiple commands\!N
cd ^path1^\!N
mkdir testing\!N
cd testing\!N
^path2^ x ^path3^\!N
pause\!N
");
cmd_file_name = "c:\temp\run_commands.cmd";

// Save command file to disk
save text file(cmd_file_name, cmd_file_text, mode("replace"));

//-------------------------------------------------------------------------------
// The /c option carries out the command before terminating
run_cmds = runprogram(executable("cmd.exe"), options("/c " || cmd_file_name), readfunction("text"));

nw = new window("Output", &amp;lt;&amp;lt; modal,
	panel box("CMD output:",
		text box(run_cmds, set width(800), set wrap(800), 
				&amp;lt;&amp;lt; Set Font( "Courier New" )),
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jun 2022 16:15:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-run-multiple-CMD-commands/m-p/512290#M73981</guid>
      <dc:creator>Niros</dc:creator>
      <dc:date>2022-06-22T16:15:55Z</dc:date>
    </item>
  </channel>
</rss>

