Home > database >  Text file is busy error from a shell script file
Text file is busy error from a shell script file

Time:09-24

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:
                            self.installShell.write(self.fullInstall)
                            print("SOFTWARE IS NOW READY")
                            ShellScriptHandeler.OpenShellscript.installSoftware()

And I run the Shell file with this:

    def installSoftware(self):
        self.shellscript = subprocess.Popen([self.installPath], shell=True, stdin=subprocess.PIPE )
        self.shellscript.stdin.write('yes\n'.encode("utf-8"))
        self.shellscript.stdin.close()
        self.returncode = self.shellscript.wait()

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

CodePudding user response:

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

  • Related