=begin run.rb Copyright (c) 2004 by Jesse van den Kieboom This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Defines: run - open a world crun - send all connected worlds the same text =end def register_functions $scripts.register("run", "use: /run \nruns in a subshell and sends output to the world") $scripts.register("crun", "use: /crun \nsame as /run except it sends output to a channel") end def run(argstr) io = IO.popen(argstr) if (io) $world.sendln(":LINUXes `" + argstr + "`") while ((l = io.gets)) $world.sendln("emote | " + l[0..-2]) end io.close else $world.writeln("Script error: can not execute #{argstr}!") end end def crun(argstr) ar = argstr.split(" ", 2) if (ar.length != 2) $world.writeln("Script error: use /crun ") else io = IO.popen(ar[1]) if (io) $world.sendln(ar[0] + " :LINUXes `" + ar[1] + "`") while ((l = io.gets)) $world.sendln(ar[0] + " :| " + l[0..-2]) end io.close else $world.writeln("Script error: can not execute #{ar[1]}!") end end end