Difference between revisions of "Shell.run"
From ComputerCraft Wiki
Smiley43210 (Talk | contribs) m (Changed to use type template, italicized args in context) |
Bomb Bloke (Talk | contribs) (Notes re parameters.) |
||
| Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=shell.run | |name=shell.run | ||
| − | |args= {{type|string}} program [, {{type|string}} | + | |args= {{type|string}} program [, {{type|string}} args1, {{type|string}} args2, ...] |
|returns={{type|boolean}} success | |returns={{type|boolean}} success | ||
|api=shell | |api=shell | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
| − | |desc=Runs ''program'' with | + | |desc=Runs ''program'' with as many specified arguments as are provided.<br><br> |
| + | |||
| + | Essentially takes all parameters passed to it and runs them as one line - for eg, shell.run("monitor","top","alongtimeago") is the same as shell.run("monitor top alongtimeago"), so use whichever syntax happens to suit you.<br><br> | ||
| + | |||
| + | See also: [[shell.openTab|shell.openTab()]] | ||
|examples= | |examples= | ||
{{Example | {{Example | ||
| − | |desc=Runs the program " | + | |desc=Runs the program "myProgram" with arguments "test" and "ing": |
| − | |code=shell.run(" | + | |code= shell.run("myProgram", "test", "ing") |
| − | |output=The program | + | |output=The program myProgram with the arguments "test" and "ing". |
| + | }} | ||
| + | {{Example | ||
| + | |desc=Runs the program "myProgram" with arguments set in "myTable": | ||
| + | |code= local myTable = {"monitor","left","worm"} | ||
| + | |||
| + | shell.run( unpack(myTable) ) | ||
}} | }} | ||
}} | }} | ||
[[Category:API_Functions]] | [[Category:API_Functions]] | ||
Revision as of 06:42, 3 April 2014
| Runs program with as many specified arguments as are provided. Essentially takes all parameters passed to it and runs them as one line - for eg, shell.run("monitor","top","alongtimeago") is the same as shell.run("monitor top alongtimeago"), so use whichever syntax happens to suit you. | |
| Syntax | shell.run(string program [, string args1, string args2, ...]) |
| Returns | boolean success |
| Part of | ComputerCraft |
| API | shell |
Examples
| Runs the program "myProgram" with arguments "test" and "ing": | |
| Code |
shell.run("myProgram", "test", "ing")
|
| Output | The program myProgram with the arguments "test" and "ing". |
| Runs the program "myProgram" with arguments set in "myTable": | |
| Code |
local myTable = {"monitor","left","worm"}
shell.run( unpack(myTable) )
|