This is my first ever post on here, and I’m coming here because I’ve hit a really big roadblock, and after days and days of trying to research possible answers, I’ve unfortunately come up short. I’ve also just started to learn how to program about 2 weeks ago, so please excuse me in advance if I say something incorrectly. :^)
So here’s the crux: I’ve trying to open a particular file (a save file exported from a PS2 Save Builder) using a Java program (a .jar file) through a Python script I’ve created. At first, I couldn’t the script to open the file, but I was finally (!) able to do so after creating an Apple .app file with a Unix executable where I could then open the .jar file as if it were an .app file. Now, I’m able to open the program using my script on its own, but I can’t get it to open the save file using that program as well. Here is the code I’m currently working with:
import subprocess import time File = (absolute path to Save File) Editor = (absolute path to Program) a = subprocess.Popen([Editor, File], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) time.sleep(10) a.terminate()
This code opens the program for me, waits for 10 seconds, and then closes the program all perfectly. But for some reason, I can’t seem to find a way to also open the file! I’ve tried subprocess.run(), playing with inputs, and it won’t work. I’ve tested the code out with a spreadsheet and Excel, and a text document and Word, and those work just fine.
I assume I’m missing a piece where I have to tell the computer that the File is indeed a file I’d like to open with the program, but I haven’t been able to find the style to write that.
Any help will be greatly appreciated! Thank you in advance. 😀
(Working on a macOS Big Sur computer.)
Leave an answer