Re: os.popen vs os.system



rbt wrote:
Is it more appropriate to use os.popen or os.system on a windows XP client? I'm calling the operting system's shutdown function like this:

restart = os.popen(shutdown -r -f)
print restart.read()
restart.close()

I don't think there's any significant difference between the above (assuming you add in the missing quotation marks) and os.system('shutdown -r -f'), except that the os.system() approach is shorter and more readable if you are simply discarding or printing the output like that.


> If it matters, I'm doing this remotely over sockets.

You can't be doing exactly that, since there are no sockets involved... do you mean the above call is executed -- on the receiving end -- after some signal is received via a socket in another part of the code? That's not going to have any effect on things...

-Peter
.



Relevant Pages

  • Re: socket communication / callback
    ... > I'm wondering if it's possible to use sockets for the folloing purpose: ... > A running process acts as a kind of server, ... > The receiving should trigger some functions (some display update based on ... toolkits provide an event loop already; if not then there are systems on ...
    (comp.lang.perl.misc)
  • What to do? lock()? invoke()? begininvoke()?
    ... I have an application using sockets, and it uses the asynchronous method ... for receiving ... The question is, in "mySocketClass", what is the best way to send an ... What is the best way to send events from a worker thread to the main ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Subprocess with a Python Session?
    ... This is one of the more reliable methods since upon receiving a packet ... Using the readline method on file objects created from sockets ... flush(), if you want to do many records, or closeas Fredrik said if only one ...
    (comp.lang.python)
  • Re: socket programming
    ... Thank you David, as u said it is correct, but I am not receiving any ... opening lots of sockets for communciation ... examples for clients, simple servers, multi-protocol servers, ...
    (microsoft.public.vc.mfc)