Sha256: 8c63f78b18bc35006e0cc683f5d0d1cc8114b1a2c9d75a1a3d686ec6e656b127
Contents?: true
Size: 1.3 KB
Versions: 16
Compression:
Stored size: 1.3 KB
Contents
module Cinch module Plugins class Exec include Cinch::Plugin match /do ([^ ]*)( ?.*)/ set :plugin_name, 'exec' set :help, <<EOT Exec is a commandline execution proxy: do <command> <pipe-grep> (only the 5 first lines will be displayed) .do psaux : rnning processes .do df : Disk free .do last : last logged .do free : free mem .do who : who is logged .do uptime : uptime and load average EOT def new(bot) @bot = bot end def exec(command,args) commands = { 'psaux' => 'ps -aux', 'df' => 'df -h', 'last' => 'last', 'free' => 'free -mol', 'who' => 'w -shuo', 'f' => 'fortune', 'uptime' => 'uptime' } if command == 'help' return commands.inspect elsif !commands[command].nil? args.strip! line = commands[command] unless args.nil? || args == '' line += ' | grep ' + args.gsub(/;|&/,'') end line += '| head -5' #back = line + "\n" back = `#{line}` return back else return "Command #{command} not found" end end def execute(m,command,args) m.reply(exec(command,args)) end end end end
Version data entries
16 entries across 16 versions & 1 rubygems