0

While trying to integrate sqlmap with my automation tool, when tried to run the command and save the output into a file, the line after which user's input is required is not getting printed on the console; It is getting printed after the arguments are passed. It is required that the console output to be printed on both the places (terminal and output file). As sqlmap requires the user's input during execution cannot use subprocess.check_output() image

Code snippet:

[try:
            cmd = cmd.rstrip()
            process = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
                while True:
                    out = process.stdout.readline()\[0:\]
                    if out == '' and process.poll() is not None:
                            break
                    if out:
                            output += out                           
                            print(out.strip())

        except Exception as e:
            exception_message = str(e)
            output += exception_message
            if 'exit status 1' not in exception_message:
                self.utilities.print_color("\[!\] Error executing the command: " + cmd,'red')
            output += '\r\n'

        print(output)
        return output][1]
  • Maybe the indentation problem after : `if out:`, you should indent `output += out` and the next line – Tinmarino Dec 05 '19 at 16:01
  • Thanks for the comment, there is no issue with the indentation. It was an issue when i copy pasted the code. Edited the code snippet and the description. – sai praneth Dec 05 '19 at 23:18

0 Answers0