Text file is busy error from a shell script file


I am currently working on a project that writes and executes a shell script based on the input of the user.

           if self.ShellInput == "install":
                    if self.enterdPassword == True:
                        self.instPack = input(str("Package Name: "))
                        self.fullInstall = "echo " + self.userPassword + " | sudo -S apt -y install " + self.instPack
                        with open('install.sh', 'w') as self.installShell:
                            print("SOFTWARE IS NOW READY")

And I run the Shell file with this:

    def installSoftware(self):
        self.shellscript = subprocess.Popen([self.installPath], shell=True, stdin=subprocess.PIPE )
        self.returncode = self.shellscript.wait()

But whenever the code executes the shell script, I get the error message: Text file is busy


All I had to do is close the file before executing it as described in the first comment.

Answered By – Teer 2008

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published