Hey
My first post here and hoping to get a solution to my problem.
I have a query regarding launching an external bash script file (.sh) in FreeBSD from within a Python script.
For Linux I used:
For Mac:
And for windows:
I am unable to get any of these to work for FreeBSD. I know startfile is only for Windows, however was wondering if there was an equivalent for FreeBSD without using subprocess.
Or if not possible at all how to use subprocess to call a external script.
Any help would be appreciated
What I have tried thus far:
Which runs without throwing any errors but does not call the .sh file!
Tried the code below as well, runs without errors but does not launch the file
Double checked the file that is to be called has been given
Yes, I did initially use the hash-bang
however whilst researching FreeBSD found a solution stating that
needs to be used, changed it, no difference.
The plugin(where the Python code resides and runs) has been given(along with all pre-existing plugins that already have the permission) drwxr-xr-x. (
)
When debugging the same for Linux, found the permissions to be the culprit, until the correct permissions were given to the plugin.bundle and the .sh file, nothing would run, hence double checking permissions but maybe I am doing something wrong?
Just to confirm the path/to/file.sh was correct and it in fact could be called, used import io and wrote something into the .sh file
It wrote bingo into the open.sh file successfully. So the path and permissions seem ok...
My first post here and hoping to get a solution to my problem.
I have a query regarding launching an external bash script file (.sh) in FreeBSD from within a Python script.
For Linux I used:
Code:
os.system(‘sh ‘+ filepath)
Code:
os.system(‘open ‘+ filepath)
Code:
os.startfile(filepath)
I am unable to get any of these to work for FreeBSD. I know startfile is only for Windows, however was wondering if there was an equivalent for FreeBSD without using subprocess.
Or if not possible at all how to use subprocess to call a external script.
Any help would be appreciated
What I have tried thus far:
Code:
process = subprocess.Popen(['/bin/sh','-c',str(filepath)], stdout=subprocess.PIPE)out= process.communicate()
Which runs without throwing any errors but does not call the .sh file!
Tried the code below as well, runs without errors but does not launch the file
Code:
subprocess.call(str(filepath), shell=True)
Double checked the file that is to be called has been given
chmod 755
permissions, making it executable, furthermore, removed the .sh and tried to call, no joy. Although double clicking the open or open.sh file does bring up a dialog stating: "Do you want to run open.sh, or display its contents? open.sh is an executable text file." At which point I hit "Run in Terminal" or "Run" producing the same effect or executing the script flawlessly. (Have MATE GUI installed on FreeBSD)Yes, I did initially use the hash-bang
Code:
#!/bin/env bash
Code:
#!/bin/sh
The plugin(where the Python code resides and runs) has been given(along with all pre-existing plugins that already have the permission) drwxr-xr-x. (
Code:
first run chown plex:plex xyz.bundle and then chmod 755 xyz.bundle
When debugging the same for Linux, found the permissions to be the culprit, until the correct permissions were given to the plugin.bundle and the .sh file, nothing would run, hence double checking permissions but maybe I am doing something wrong?
Just to confirm the path/to/file.sh was correct and it in fact could be called, used import io and wrote something into the .sh file
Code:
f = io.open(filepath,'wb')
f.write('bingo')
It wrote bingo into the open.sh file successfully. So the path and permissions seem ok...