title: ComputerCraft: Using shell.run() command in a program
body: <p>I am trying to use the <code>(file , parameters</code>) functionality of the <code>shell.run()</code> command by assigning each word in a string to a new variable. The only way I know to do this is with <code>tArgs[#]</code>.
  Which if at the command line and typing a name of a program and its arguments that uses <code>tArgs</code> to do so will work fine. But I want to do this from a prompt within a program. So the scenario is:</p>
  
  <pre><code>1.The computer starts a program using the startup file.
  
  2.Using the "write()" command the program asks for a command to run with parameters.
  
  3.The user types for ex. "echo yes"
  
  4.The program then takes the word "echo" and assigns it to "var1" and then the
   word: "yes" and assigns it to "var2"
  
  5.The program takes "var1" and "var2" and inputs it to the "shell.run()" command in the
   format: shell.run((var1),(var2))
  
  6.The "shell.run()" calls a program named "echo" which is set up to allow
    for parameters to be entered without a prompt by using the "tArgs = {...}" command
    and the "echo" program sees that it is getting an argument "yes" and runs the
    command: "print(tArgs[1])"
  </code></pre>
  
  <p>I have been working furiously trying to figure this out but cannot get it to work.
  Here is some code I have put together.</p>
  
  <p><code>------------------------------------------------------------</code></p>
  
  <pre><code>-- 1.At the CraftOS the startup file runs a program "cmd"
  
  [[Program: startup]]
  
  shell.run("cmd")
  
  [[end of startup]]
  
  --2.Runs program "cmd"
  
  [[Program: cmd]]
  
  -- Now in cmd
  
  term.clear()
  term.setCursorPos(1,1)
  
  function prompt()
  
  write("&gt;") --assuming user typed: echo yes
  tArgs = {...}
  
  file = tArgs[1] --will get the word "echo"
  param1 = tArgs[2] --will get the word "yes"
  
  if #tArgs &lt; 1 then
  
      print(Syntax: &lt;command&gt; &lt;parameters&gt;)
      prompt()
  else
      print()
      shell.run((file), (param1)) --resulting command is shell.run("echo","yes")
      print()
      prompt()
  end
  end
  
  prompt()
  
  [[end of cmd]]
  
  --3.Runs the program "echo" because it was the first word in our command.
  
  [[Program: echo]]
  
  tArgs = {...}
  param = tArgs[1]
  
  print(param) --prints "yes" which is what the "shell.run((file), (param1)) is referring to.
  
  [[end of echo]]
  </code></pre>
  
  <p>And the result of this should be like so in program "cmd" as this is where the custom shell is.</p>
  
  <pre><code>&gt;echo yes
  
  yes
  
  &gt;
  
  --4.Then because functions return after completion it should loop back into function prompt().
  </code></pre>
  
  <p>Any help is greatly appreciated, if you have any advice please supply code that shows how you are using it in a program.
  Thank you!</p>