Python Forum
Thread Rating:
  • 3 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
System Command
#1
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
Reply
#2
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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
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!!
Reply
#4
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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Os.system("shutdown"); command not found cosmin1805 4 1,616 Nov-13-2022, 02:07 PM
Last Post: cosmin1805
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,492 Jan-11-2021, 06:30 PM
Last Post: ykumar34
Question Difference between Python's os.system and Perl's system command Agile741 13 6,651 Dec-02-2019, 04:41 PM
Last Post: Agile741
  run command on system with multi qoutes evilcode1 16 6,389 Aug-31-2018, 05:19 PM
Last Post: evilcode1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020