import subprocess
import os 
m_list = [5, 10, 15, 20, 25, 30]#[5, 10, 15, 20, 25, 30, 50, 100] #[7, 14, 28, 84]
path = os.getcwd()
print(path)

processes = []
for seed in range(6):
    for InSamNo in m_list:
        # subprocess.run(["chmod", "+x", script_path])  # This makes the script executable
        output_file = 'results/RSOME2/%s_seed%s-%s.out'%(InSamNo, seed*10, seed*10+9)
        with open(output_file, 'w') as f:
            # Start each script in a new subprocess with nohup and redirect the output
            p = subprocess.Popen(['nohup', 'python', 'run_RSOME.py', '%s'%InSamNo, '%s'%seed], stdout=f)
            processes.append(p)

for p in processes:
    p.wait()