user2234234
user2234234

Reputation: 349

Run subprocess.call(cmd) while the cmd is a text variable

In python, is it possible to run a shell command, while the command stored in variable as text ? for example:

  self.command_editor = QTextEditor()
  self.command_editor.append("echo command")
  cmd = str(self.command_editor.toPlainText())
  call(cmd)

this code doesn`t work!

Upvotes: 0

Views: 42

Answers (1)

user2234234
user2234234

Reputation: 349

this is the right answer:

  self.command_editor = QTextEditor()
  self.command_editor.append("echo command")
  cmd = str(self.command_editor.toPlainText())
  call(cmd, shell = True) #the mistake was here

Upvotes: 1

Related Questions