Python Forum
How to use subprocess send commands to windows shell
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use subprocess send commands to windows shell
#2
Here's a modified version from python docs: https://docs.python.org/3/library/subprocess.html
run on Linux
import shlex, subprocess


def run_subprocess(command_line):
    args = shlex.split(command_line)
    print(args)
    p = subprocess.Popen(args) # Success!


if __name__ == '__main__':
    run_subprocess('/bin/ls -latr')
    run_subprocess('ls -latr /home')
Reply


Messages In This Thread
RE: How to use subprocess send commands to windows shell - by Larz60+ - Nov-21-2019, 07:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  batch file for running python scipt in Windows shell MaartenRo 2 1,958 Jan-21-2022, 02:36 PM
Last Post: MaartenRo
  cant use ping, sudo or other commands in remote shell script. throwaway34 7 3,705 May-17-2021, 11:29 AM
Last Post: throwaway34
  Using a .bat file to execute simple anaconda commands in Windows 10 gacg1 0 4,733 Nov-30-2020, 03:24 PM
Last Post: gacg1
  Need to access Windows Machine or Personal Certificate Store and send to web app seswho 0 1,671 Sep-14-2020, 04:57 PM
Last Post: seswho
  Subprocess command prompt (Windows) arnaur 6 10,441 Sep-06-2018, 07:22 AM
Last Post: arnaur
  Subprocess output in windows Ohmganesh83 5 8,799 Aug-20-2018, 02:32 PM
Last Post: Ohmganesh83
  [inconsistent output] subprocess.call to run cmd commands to get Kerberos ticket Yelin 2 5,061 Jun-08-2018, 09:02 AM
Last Post: Yelin
  SOLVED: best way to block (wait on) shell calls to multiple windows programs at once? ezdev 0 2,630 Dec-10-2017, 06:42 AM
Last Post: ezdev
  Windows/linux shell emulation AceScottie 3 3,486 Nov-27-2017, 01:31 PM
Last Post: wavic
  os.environ not setting current shell variables in Windows? brian6667 2 10,888 Apr-26-2017, 12:59 PM
Last Post: brian6667

Forum Jump:

User Panel Messages

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