title: Stopping and starting a server in a python script using subprocess
body: <p>From my python script i need to stop and start Weblogic server multiple number of times.</p>
  
  <p>If we need to do that manually (stopping or starting the server ) in linux</p>
  
  <p>I go to 
      mwhome+"/user_projects/domains/bifoundation_domain/bin
  and execute the command</p>
  
  <pre><code>./stopWeblogic.sh
  </code></pre>
  
  <p>ANd to start the server in a terminal i execute the command </p>
  
  <pre><code>./startWeblogic.sh
  </code></pre>
  
  <p>And i need to replicate this in my python code.</p>
  
  <pre><code>wlserverstop=mwhome+"/user_projects/domains/bifoundation_domain/bin/stopWebLogic.sh"
  output3 = subprocess.call([ wlserverstop ])
  
  #starting weblogic server
  wlserver=mwhome+"/user_projects/domains/bifoundation_domain/bin/startWebLogic.sh"
  output4 = subprocess.Popen([ wlserver],stderr=STDOUT, stdout=PIPE)
  time.sleep(200)
  </code></pre>
  
  <p>1) As the stopWeblogic server will terminate and return i used subprocess.call()
  2) As the startWeblogic server will not terminate and a process needs to be running in the background i used subprocess.Popen()</p>
  
  <p>But the problem is the stopping and starting of servers is not happening properly.
  Some times it doesnot start and sometimes even if the server starts when i put a stopserver command immeadiately it runs forever.</p>
  
  <p>Any better way to do this ? Thanks</p>