I would like to call a script in PowerShell so that the script can be called from any directory on the computer. I am using environment variables to call the script from a library directory. However, the script requires a argument in the call eg. script.py argv[1].
It looks to me as though the arguments are not being passed from the PowerShell command line when calling the python script. As an example I believe the following is occurring: I run the script as below
script.py argv[1] This is passed by PowerShell to python.exe as: python script.py i.e. no arguments forwarded to the python execution
This script is run on a file and the argument passed is the file name to be processed. This operation is carried out on a number of files in different locations and
I have looked online for a similar issue without luck. The last attempt is to ask here. I created a brief script to call out the arguments that have been passed.
print('Argument = ', sys.argv[0])
print('All = ', sys.argv)
No matter what I've tried the sys.argv list is always a single item argv[0] which contains the path for the script.py file.
I'm not fully familiar with the PowerShell commands but have tested the following:
- & script.py $argv1
- & script.py $argv1 = argument1