I am new to programming but I have been having a muck around in python.
My current project is a self replicating code, however this requires one command that I cant find anyware, the project consists of two scripts, one to start the thing off and the other copies it self.
However I don’t know the command to make one python script run another
P.S. G:\ is a flash drive
the starter:
Code:
def write(name, text):
out_file = open(name, "w")
out_file.write(text)
out_file.close()
def read(name):
in_file = open(name, "r")
text = in_file.read()
in_file.close()
return text
text = 'def write(name, text):\n out_file = open(name, "w")\n out_file.write(text)\n out_file.close()\ndef read(name):\n in_file = open(name, "r")\n text = in_file.read()\n in_file.close()\n return text\nwhile 1 == 1:\n try:\n this_name = read("name_list")\n except IOError:\n write("name_list", "0")\n this_name = "0"\n this_name = int(this_name)\n next_name = str(this_name + 1)\n this_name = str(this_name)\n write(next_name + ".py", read(this_name + ".py"))\n write("name_list", next_name)'
try:
num = int(read('G:/bomb/name_list'))
num = str(num + 1)
except IOError:
num = "0"
write('G:/bomb/' + num + ".py", text)
#run ('G:/bomb/' + num + ".py")
and the main thing:
P.S. this is made by the first one.
Code:
def write(name, text):
out_file = open(name, "w")
out_file.write(text)
out_file.close()
def read(name):
in_file = open(name, "r")
text = in_file.read()
in_file.close()
return text
while 1 == 1:
try:
this_name = read("name_list")
except IOError:
write("name_list", "0")
this_name = "0"
this_name = int(this_name)
next_name = str(this_name + 1)
this_name = str(this_name)
write(next_name + ".py", read(this_name + ".py"))
write("name_list", next_name)
#run(next_name + ".py")