Python Forum
calling a variable in a for loop in windows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
calling a variable in a for loop in windows
#1
I am new to python and I am trying to figure out how to call some windows commands inside a python script, below is the powershell script that works but I can't figure out how to convert this to python with the subprocess command any help would be appreciated.

horcmstart 100 101

$servers = @(“dc2pa90048”,”tocpaIIB-TI”,”lsys7011a-TI”,"powerlink-asys002-TI")
Foreach ($server in $servers) {
	pairdisplay -IM100 -g $server -fcx
    
	start-sleep -s 1 
    "`n"
}
Reply
#2
You can use system().
installs pip-review.
system("pip install --user pip-review")

clears screen.
system("clear")

Note: The commands must be strings.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable definitions inside loop / could be better? gugarciap 2 440 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  working directory if using windows path-variable chitarup 2 733 Nov-28-2023, 11:36 PM
Last Post: chitarup
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,720 Nov-07-2023, 09:49 AM
Last Post: buran
  Calling functions by making part of their name with variable crouzilles 4 833 Nov-02-2023, 12:25 PM
Last Post: noisefloor
  PyRun_SimpleFile calling multiprocessing Python Class cause endless init loop Xeno 2 1,047 Sep-19-2022, 02:32 AM
Last Post: Xeno
  Nested for loops - help with iterating a variable outside of the main loop dm222 4 1,589 Aug-17-2022, 10:17 PM
Last Post: deanhystad
  loop (create variable where name is dependent on another variable) brianhclo 1 1,140 Aug-05-2022, 07:46 AM
Last Post: bowlofred
  Multiple Loop Statements in a Variable Dexty 1 1,204 May-23-2022, 08:53 AM
Last Post: bowlofred
Big Grin Variable flag vs code outside of for loop?(Disregard) cubangt 2 1,174 Mar-16-2022, 08:54 PM
Last Post: cubangt
  How to save specific variable in for loop in to the database? ilknurg 1 1,149 Mar-09-2022, 10:32 PM
Last Post: cubangt

Forum Jump:

User Panel Messages

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