Python Forum
System Command - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: System Command (/thread-3011.html)



System Command - sushmita13 - Apr-24-2017

my question here


def systemCommand(cmd):
terminalProcess = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
terminalOutput, stderr = terminalProcess.communicate()
What do these lines mean?
Thanks  Smile


RE: System Command - wavic - Apr-24-2017

It is a definition of a function called systemCommand.
You completely missed the Python tags where you have to put your code. No indentation at all

The function doesn't return an object


RE: System Command - sushmita13 - Apr-25-2017

def systemCommand(cmd):
terminalProcess = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
terminalOutput, stderr = terminalProcess.communicate()
Apart from definition what does it do? What's the function of this def?

def systemCommand(cmd):
terminalProcess = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
terminalOutput, stdef systemCommand(cmd):

def systemCommand(cmd):
      terminalProcess = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
      terminalOutput, stdef systemCommand(cmd):
I am new to the forum , sorry for not indenting!!


RE: System Command - wavic - Apr-25-2017

It executes a shell command passed as an argument to the function.
Then gets the output but nothing else. The output is not returned and nothing else is happening except the shell command execution.

See: https://docs.python.org/3.5/library/subprocess.html