issue with pexpect

2011-10-05 Thread Daniel
Hello,
For about week i am experiencing a problem with pexpect that's why i
hope you can help me :).
Following is my code which tries to remove some files from the root dir
and the code works on linux debian and freebsd but with no success on
linux fedora .. any idea why this happen only in fedora ?

#!/usr/bin/env python
from __future__ import print_function
import sys
import pexpect
import time

spa=pexpect.spawn('su root')
spa.expect('.*')
print(spa.after)
spa.sendline('abc')
spa.expect('.*')
print(spa.after)
spa.sendline('rm -rf /root/py/pe*')
spa.expect('.*')
print(spa.after)
spa.close()


this is the output in Fedora linux  it looks that the script can't
authenticate as root

python]$ ./sk64.py 
Password: 


rm -rf /root/py/pe*


i appreciate any help thanks in advance

-- 
http://mail.python.org/mailman/listinfo/python-list


issue with pexpect

2011-10-05 Thread Daniel
Hello,
For about week i am experiencing a problem with pexpect that's why i
hope you can help me :).
Following is my code which tries to remove some files from the root dir
and the code works on linux debian and freebsd but with no success on
linux fedora .. any idea why this happen only in fedora ?

#!/usr/bin/env python
from __future__ import print_function
import sys
import pexpect
import time

spa=pexpect.spawn('su root')
spa.expect('.*')
print(spa.after)
spa.sendline('abc')
spa.expect('.*')
print(spa.after)
spa.sendline('rm -rf /root/py/pe*')
spa.expect('.*')
print(spa.after)
spa.close()


this is the output in Fedora linux  it looks that the script can't
authenticate as root

python]$ ./sk64.py 
Password: 


rm -rf /root/py/pe*


i appreciate any help thanks in advance 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: issue with pexpect

2011-10-05 Thread Daniel
there is no such implementation in fedora you can su as a root .. i can
su from regular user to root with no problems 
the problem come when i use the pexpect module

On Wed, 2011-10-05 at 14:47 +0200, Nizamov Shawkat wrote:
 2011/10/5 Daniel 5960...@gmail.com:
  Hello,
  For about week i am experiencing a problem with pexpect that's why i
  hope you can help me :).
  Following is my code which tries to remove some files from the root dir
  and the code works on linux debian and freebsd but with no success on
  linux fedora .. any idea why this happen only in fedora ?
 
  #!/usr/bin/env python
  from __future__ import print_function
  import sys
  import pexpect
  import time
 
  spa=pexpect.spawn('su root')
  spa.expect('.*')
  print(spa.after)
  spa.sendline('abc')
  spa.expect('.*')
  print(spa.after)
  spa.sendline('rm -rf /root/py/pe*')
  spa.expect('.*')
  print(spa.after)
  spa.close()
 
 
  this is the output in Fedora linux  it looks that the script can't
  authenticate as root
 
 
 Hi!
 
 The problem may be that root user is disabled. This was introduced in
 Ubuntu long ago and I believe that later this was also accepted in
 Fedora. That means that you simply can not su to root, no matter
 what password you supply. This is the way how your OS operates and is
 not connected in any way to python or pexpect. Therefore, either use
 sudo (generally recommended) or enable root user (insecure!).
 
 Hope it helps,
 S.Nizamov


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: issue with pexpect

2011-10-05 Thread Daniel
Okey i figure it out how to do the job in fedora
i added slight delay before sending each command
either by the delaybeforesend attribute or by the time module
;)


cheers

On Wed, 2011-10-05 at 14:47 +0200, Nizamov Shawkat wrote:
 2011/10/5 Daniel 5960...@gmail.com:
  Hello,
  For about week i am experiencing a problem with pexpect that's why i
  hope you can help me :).
  Following is my code which tries to remove some files from the root dir
  and the code works on linux debian and freebsd but with no success on
  linux fedora .. any idea why this happen only in fedora ?
 
  #!/usr/bin/env python
  from __future__ import print_function
  import sys
  import pexpect
  import time
 
  spa=pexpect.spawn('su root')
  spa.expect('.*')
  print(spa.after)
  spa.sendline('abc')
  spa.expect('.*')
  print(spa.after)
  spa.sendline('rm -rf /root/py/pe*')
  spa.expect('.*')
  print(spa.after)
  spa.close()
 
 
  this is the output in Fedora linux  it looks that the script can't
  authenticate as root
 
 
 Hi!
 
 The problem may be that root user is disabled. This was introduced in
 Ubuntu long ago and I believe that later this was also accepted in
 Fedora. That means that you simply can not su to root, no matter
 what password you supply. This is the way how your OS operates and is
 not connected in any way to python or pexpect. Therefore, either use
 sudo (generally recommended) or enable root user (insecure!).
 
 Hope it helps,
 S.Nizamov


-- 
http://mail.python.org/mailman/listinfo/python-list