I am trying to run AVL (Athena Vortex Lattice) with Python. It's a software that runs on a separate terminal window, exactly like XFOIL. The user writes commands and presses enter to execute.
I am using the subprocess
module to run the software, and the terminal window opens as expected. However, I can't get my Python program to write commands into the opened window. I don't get any error, but nothing is written to AVL, and it stays in its initial state.
The command I am trying to write to AVL is LOAD
followed by an absolute path to an input file.
This is the first time I'm using the subprocess module, so I may just have forgotten an essential option somewhere. I'm running the program with Python 3.9 on macOS.
What could be wrong?
import os.path
import subprocess as sp
AVL_FOLDER_PATH = '~/Desktop/AVL_VLM'
AVL_EXE_NAME = 'avl335'
avl_path = os.path.join(AVL_FOLDER_PATH, AVL_EXE_NAME)
avl_open_cmd = 'open ' + avl_path
avl_ps = sp.Popen([avl_open_cmd], stdin=sp.PIPE, stdout=None, stderr=None, shell=True)
def avl_command(cmd):
cmd += '\n'
cmd = cmd.encode('ascii')
avl_ps.stdin.write(cmd)
avl_command('LOAD')
avl_command('/Users/vianneydubois/Desktop/AVL_VLM/test_gen.avl')