Invoking Python subprocess in Streamlit to run Linux script file

I’m a bit turned around on how to execute a shell script file in a Linux environment via Python’s subprocess command in Streamlit. Any assistance on what I’m missing is appreciated.

I’m using a shell script called to run Pylanguagetool for a grammar check of one text file and return corrections in another text file, like so:

cd /home/user/dir/TXTs/

pylanguagetool text_0.txt > comments_0.txt

This script runs correctly in the Linux terminal, writing a comments_0.txt with appropriate grammar checks from text_0.txt.

I need to create a Python/Streamlit app that runs these shell scripts. In attempting to run this shell script, I’ve written below:

import os
import subprocess
import sys['bash','/home/user/dir/Scripts/'])

I then run in Streamlit via the code below, keeping with Streamlit’s documentation on using subprocess here.

import streamlit as st
import os
import subprocess
import sys

def app():

    button1 = st.button("Click me")
    if button1:

        p =[f"{sys.executable}", "/home/user/dir/pages/"])

When I execute the via Streamlit, the script executes, writing comments_0.txt in the correct directory and providing the following traceback: CompletedProcess(args=['/usr/bin/python3', '/home/user/dir/pages/'], returncode=0). However, the comments_0.txt output contains the error input file is required, as if it can’t properly access or read text_0.txt. I’ve tinkered around trying to find the problem, but have hit a brick wall.

Any suggestions on what I’m missing, or paths forward? Any help greatly appreciated.

I do this kind of stuff all the time successfully, so I am sure this is a path or working directory problem. I can’t quite see it, though.