0

So I've got a script located here: https://bpa.st/NXFA

The desired end result is to call this .py from a powershell script but to include the variables from powershell as arguments for python.

For example the powershell side collects variables via a number of: $username = write-host "Enter User name"

So I want to then pass $username to the line calling Python like: start-process python -ArgumentList '-u ".\Create_mailbox.py -user $username -fname $fname -lname $lname -password $password -dname $displayname"' -NoNewWindow -Wait

Skeer
  • 153
  • 11
  • Maybe.. am I understanding argv correctly in that, say you have a command: python script.py -arg1 -arg2 Using sys.argv does this mean further down in the script you can reference the arguments like: fname = driver.find_element_by_xpath('//dhjkfhdjfhdjfdjkf').send_keys(sys.argv[2]) ? – Skeer Oct 14 '20 at 19:14
  • 1
    Sure, you can index into `argv`. `argv[2]` would be the string value `-arg2` in your example – Mathias R. Jessen Oct 14 '20 at 19:26
  • Oh wow.. OK so I'm pretty sure I can see this in my head.. but putting the syntax into an IDE is different. I'm looked at articles on python.org and I just cannot see how to handle these when all 6 options are required. Looking here: https://docs.python.org/2.6/library/getopt.html I see an else/if loop. That's not what I need. Any chance someone has a script I can view as an example of multiple requires options w/arguments? – Skeer Oct 15 '20 at 12:26

0 Answers0