<font size="4">I <font size="4">just start to use tor cont<font size="4">roller,  <font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4">I no<font size="4">tice the mannual says:<br>
</font></font></font></font></font></font></font></font></font></font></font></font><br><pre><font size="4"> pass Tor the "--CookieAuthentication 1" option when you start it.  Tor will create a file in its data directory<br>
 called "control_auth_cookie".  All your controller needs to do is to pass<font size="4"> </font>the contents of this file to authenticate() <br><font size="4"> </font>when it connects to Tor.</font><br><br> <br>
</pre><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"> there are two kind<font size="4">s of Tor, on<font size="4">e i<font size="4">s ins<font size="4">talled and can be r<font size="4">un by command "tor"<br>
<font size="4">the other is Tor <font size="4">Browser Bundle, <br><br>1) with command "tor", when it establishe<font size="4">s, if I run <font size="4">example.py<br>the result is <br><font size="4">           "Connection refused. Is the ControlPort enabled?"<br>
</font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><br>
<font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4">I tried command:  <font size="4">"tor</font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><font size="4"> --CookieAuthentication 1</font><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4">"<font size="4">  to start <font size="4">Tor<font size="4">,</font><br>
<font size="4">but I can't find the so called data dire<font size="4">ctory, and the running information says:<br><font size="4">                        Could not open "/etc/tor/torrc": Permission denied<br>
<br></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font>2) with TBB, after I start<font size="4">ed TBB, if I run example.py,<br>
<font size="4">it seems it can connect to </font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4">ControlPort, but it promp<font size="4">ts for a pas<font size="4">sword<br>
<font size="4">there is a Data directory in TBB, but I can't find the  so called </font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><font size="4"><font size="4">"</font>control_auth_cookie</font><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4">" <br>
<font size="4">file, so when I run TBB,<font size="4"> </font></font>how can I pas<font size="4">s "</font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4"><font size="4">--CookieAuthentication 1</font>" to tor?</font></font></font><br>
</font></font></font></font></font></font></font></font></font></font><br><br><font size="4">example.<font size="4">py<font size="4"> : <br><br></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font>import time<br>
import TorCtl<br><br>class BandwidthListener(TorCtl.PostEventListener):<br>  def __init__(self):<br>    TorCtl.PostEventListener.__init__(self)<br><br>  def bandwidth_event(self, event):<br>    print "tor read %i bytes and wrote %i bytes" % (event.read, event.written)<br>
<br># constructs a listener that prints BW events<br>myListener = BandwidthListener()<br><br># initiates a TorCtl connection, returning None if it was unsuccessful<br>conn = TorCtl.connect()<br><br>if conn:<br>  # tells tor to send us BW events<br>
  conn.set_events(["BW"])<br><br>  # attaches the listener so it'll receive BW events<br>  conn.add_event_listener(myListener)<br><br>  # run until we get a keyboard interrupt<br>  try:<br>    while True:<br>
      time.sleep(10)<br>  except KeyboardInterrupt: pass<br></font><br><br></font></font></font>