Advertisement
teslariu

subprocess

Feb 18th, 2022
649
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5.  
  6. C:\Users\Usuario\Desktop>hostname
  7. DESKTOP-SBRCMHE
  8.  
  9. C:\Users\Usuario\Desktop>whoami
  10. desktop-sbrcmhe\usuario
  11.  
  12. C:\Users\Usuario\Desktop>notepad
  13.  
  14. C:\Users\Usuario\Desktop>python
  15. Python 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
  16. Type "help", "copyright", "credits" or "license" for more information.
  17. >>> import subprocess
  18. >>> subprocess.run(["mkdir","PORQUERIA"], shell=True)
  19. CompletedProcess(args=['mkdir', 'PORQUERIA'], returncode=0)
  20. >>>
  21. >>>
  22. >>>
  23. >>> p = subprocess.run("hostname", capture_output=True, encoding="cp850")
  24. >>> p.stdout
  25. 'DESKTOP-SBRCMHE\n'
  26. >>> p.stdout.strip()
  27. 'DESKTOP-SBRCMHE'
  28. >>> subprocess.run("notepad", shell=True)
  29. CompletedProcess(args='notepad', returncode=0)
  30. >>>
  31.  
  32. """
Advertisement
RAW Paste Data Copied
Advertisement