does popen3 thow exceptions? how to erro check?

Rene Salmon rsalmon at
Thu Aug 16 20:52:20 CEST 2001


First I have spent lots of time on this and looked at the mailing list
and the python site and I am still not clear on how to do this so I am
posting this message.

I am trying to write a python script to change or add a users samba
this can be done by running "smbpasswd -a -s"

man smbpasswd
 -s   This option causes smbpasswd to be silent (i.e. not
               issue prompts) and to read it's old and new passwords
               from standard input, rather than from /dev/tty (like
               the passwd(1) program does). This option is to aid
               people writing scripts to drive smbpasswd

This python code seems to work great it does indeed change the samba
password or add the user if the user does not exist.

         #run smbpasswd to add user to samba
-a -s","t")

How do I check this code to make sure that there was no error when
running it??
say I mistype 

(child_stdin,child_stdout,child_stderr)=os.popen3("badcommand -a

I the program still completes and produces no errors. I tryed
enclosing the code
in a try: and except: block but that did not work   

I also tried getting the file descriptor from the file objects
using fileno() and checking the status of the file descriptor with
fstat() but that always returned true that file descriptor always gets

any ideas on how to error check popen3?

Thank you for any help or hints you can give me
please respond to me as I am not subscribed to the list.


More information about the Python-list mailing list