0

This is my code:

elif command == "3.1":
             os.system("cls")
             conn.send(command.encode())
             boxtitle = input("Please enter the title of the message : ")          
             print("[16] - Critical")
             print("[32] - Question")
             print("[48] - Warning")
             print("[64] - Info")
             boxerro = input("Please enter Error Type: ")
             box = input("Please enter the message you would like to write  : ")
             reading_file = open("errors.vbs", "r")

             new_file_content = ""
             for line in reading_file:
                 stripped_line = line.strip()
                 new_line = stripped_line.replace("x=msgbox(, 0+, )", "x=msgbox"(box, "0+", boxerro, boxtitle))
                 new_file_content += new_line +"\n"
             reading_file.close()

             writing_file = open("errors.vbs", "w")
             writing_file.write(new_file_content)
             writing_file.close()

What I'm trying to do here is when the command 3.1 is called it clears the cmd window sends this over to my client file and then it runs through what would you like I only get to the error on new_line = stripped_line.replace("x=msgbox(, 0+, )", "x=msgbox"(box, "0+", boxerro, boxtitle)) What I'm doing here is its opening errors.vbs replacing what I have with what I want and closing it but I get the error

new_line = stripped_line.replace("x=msgbox(, 0+, )", "x=msgbox"(box, "0+", boxerro, boxtitle))
SyntaxWarning: 'str' object is not callable; perhaps you missed a comma? 

But When I checked I couldn't see if I missed an error I'm really not sure how to fix these.

Hex
  • 17
  • 5
  • Does this answer your question? [How do I put a variable inside a string?](https://stackoverflow.com/questions/2960772/how-do-i-put-a-variable-inside-a-string) – mkrieger1 Feb 21 '21 at 09:52
  • See the color on the code, you can see the string parts, and the variable parts, you see that you don't replace by one string, that's the problem – azro Feb 21 '21 at 09:54
  • This, here: `"x=msgbox"(box, "0+", boxerro, boxtitle)`—what is that? – khelwood Feb 21 '21 at 09:58
  • @mkrieger1 il give it a try – Hex Feb 21 '21 at 10:24
  • This line is an error `new_line = stripped_line.replace("x=msgbox(, 0+, )", "x=msgbox"(box, "0+", boxerro, boxtitle))`. You have the to replace string incorrectly setup. – Joe Ferndz Feb 21 '21 at 17:35
  • I recommend that you use a variable like `replace_str` and assign the value to it. Then use it in the line.replace string – Joe Ferndz Feb 21 '21 at 17:38

0 Answers0