Python Forum
[subprocess]>Run a cmd command and get output into a variable
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[subprocess]>Run a cmd command and get output into a variable
#5
PATH is an environment variable, you can get the value with:

import os
path=os.environ['PATH']
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
RE: [subprocess]>Run a cmd command and get output into a variable - by Ofnuts - Mar-13-2017, 09:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to run shell command, capture the output, then write it into textfile? tatahuft 4 1,134 Dec-20-2024, 02:13 PM
Last Post: Axel_Erfurt
  Using subprocess to execute complex command with many arguments medatib531 5 9,839 Apr-27-2023, 02:23 PM
Last Post: medatib531
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 2,272 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  merge two csv files into output.csv using Subprocess mg24 9 3,832 Dec-11-2022, 09:58 PM
Last Post: Larz60+
  How to combine two output in one variable? ilknurg 2 2,058 Aug-01-2022, 09:31 AM
Last Post: Gribouillis
  How to write a part of powershell command as a variable? ilknurg 2 2,014 Jul-26-2022, 11:31 AM
Last Post: ilknurg
  Pass variable to subprocess paulo79 4 13,087 Apr-12-2022, 12:35 PM
Last Post: DeaD_EyE
  Os command output in variable shows wrong value paulo79 2 2,399 Apr-09-2022, 03:48 PM
Last Post: ndc85430
  How to use a variable in linux command in python code? ilknurg 2 2,510 Mar-14-2022, 07:21 AM
Last Post: ndc85430
  use subprocess on linux\pi wwith a "grep " command korenron 2 11,518 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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