0

I have tried subsystem and os and both will not work. I would prefer it if they were in 2 separate windows.

My current code is

os.system('cmd.exe /c Bot.py ' + user)

I have also tried

subprocess.Popen(['python', 'Bot.py', user])

and

subprocess.Popen(['python', 'Bot.py', user, '&'])

Bot.py is a irc bot. The bot will connect to the irc but not receive any messages after the connection. The bot works fine if executed alone.

Ray
  • 2,472
  • 18
  • 22
  • 1
    Are you actually assigning the result of the ``Popen`` call to a variable? If not it can be arbitrarily deleted (and thus the process killed) at any time. Also, the semantics of ``Popen`` are slightly different on Windows and Linux, so stating your OS might help (I'd guess Windows based on your first line, but better to be explicit) – aruisdante May 14 '14 at 01:14
  • I have tried assigning it to a variable and I have windows. – user3634414 May 14 '14 at 07:06
  • It's not clear to me why, since you want them in separate windows, you don't simply start them separately form the command line? – Midnighter May 14 '14 at 15:27
  • Have you tried: **os.system("start /wait cmd /c Bot.py")** ? – Mansueli May 14 '14 at 17:37
  • @aruisdante: the process *won't* be killed only because OPs code doesn't keep a reference to Popen() object. `subprocess` has `_active` list that holds Popen objects that are still running while their `__del__` method are called. – jfs May 16 '14 at 02:03
  • related: [Execute terminal command from python in new terminal window?](http://stackoverflow.com/q/19308415/4279) – jfs May 16 '14 at 02:10
  • @ Midnighter Its so someone can put my irc bot in there channel without needing me to do it manually. – user3634414 May 16 '14 at 05:04

0 Answers0