1
0
Fork 0
mirror of synced 2024-05-18 19:42:28 +12:00

Use a shell in the bash command

This commit is contained in:
Phxntxm 2018-01-11 11:07:42 -06:00
parent 11b6366360
commit 0d3ec6f46f

View file

@ -253,12 +253,12 @@ class Owner:
@commands.check(utils.is_owner) @commands.check(utils.is_owner)
async def bash(self, ctx, *, cmd: str): async def bash(self, ctx, *, cmd: str):
"""Runs a bash command""" """Runs a bash command"""
proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
output, error = proc.communicate() output, error = proc.communicate()
if output: if output:
await ctx.send("STDOUT:\n```\n{}```".format(output.decode("utf-8", "ignore"))) await ctx.send("STDOUT:\n```\n{}```".format(output.decode("utf-8", "ignore").strip()))
if error: if error:
await ctx.send("STDERR:\n```\n{}```".format(error.decode("utf-8", "ignore"))) await ctx.send("STDERR:\n```\n{}```".format(error.decode("utf-8", "ignore").strip()))
@commands.command() @commands.command()
@commands.check(utils.is_owner) @commands.check(utils.is_owner)