Mac OS 10.13.5
Xojo 2018 r1.1
My goal is to process some data in Python using the Shell.Execute command. I am passing that data as "parameters" of the Shell.Execute command. As I understand it, you can consider the string that is passed in the Shell.Execute command as a bunch of space-delimited "parameters".
If you want to fire up a Python script, then the first "parameter" I am passing is an absolute path to Python on my machine. The second "parameter" is the absolute path to the Python script that I am intending to run. After this, additional "parameters" that are provided are passed to the Python script as arguments.
For this example, consider trying to pass two strings as arguments to the Python script.
Const SPACE = " " Const PATH_PYTHON3 = "/Users/owl/anaconda3/bin/python" Const PYTHON_SCRIPT = "/Users/owl/Documents/PythonPractice/PythonLittleApps/Trial.py" Dim argument1 As String argument1 = "abcde" Dim argument2 As String argument2 = "pqrst" Dim pyShell As New Shell pyShell.Execute(PATH_PYTHON3 + SPACE + PYTHON_SCRIPT + SPACE + argument1 + SPACE + argument2)
This works fine. In the Python script I am successful in accessing the argument1 and argument2.
However, there are many characters that cause problems for me when included in argument1 or argument2 strings.
Certainly, you cannot have a space. That makes sense since spaces are used as delimiters. However, in my brief testing I have run into other problems. < and | and & are all characters that are "unacceptable" and causes errors
For example if argument1 is "abc&de" is passed I get an error.
bash: de: command not found
I deduce that "&" is a special character somehow specifying a bash command. "<" and "|" also cause trouble. I presume there are others.
Well, suffice to say, I know nothing much about bash. I do not know the language.
What I want to be able to do is to pass any string in argument1 and argument2 for processing by Python. But I am getting tripped up.
Is there some "finite" list of unacceptable characters that I can find and try to filter out? Is there some methodology that prevents the characters being passed from having some special meaning (like initiating some bash command) so they will be successfully passed to Python?