0

If i get the input as ls, how to pass the value in the call function and get output?

Example

$ Enter any command: ls

$ log.txt file.txt

user458766
  • 35
  • 6

1 Answers1

0

Simplifying Retrieving the output of subprocess.call() for the question:

from subprocess import Popen, PIPE
p = subprocess.Popen(['ls', '-l'], stdout = PIPE)
result = p.communicate()
Community
  • 1
  • 1
Eriks Dobelis
  • 913
  • 7
  • 16
  • use `subprocess.check_output()` as shown in the 2nd answer of the question that you've linked. – jfs Jul 01 '15 at 16:30