By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,814 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,814 IT Pros & Developers. It's quick & easy.

pexpect.exitstatus not working?

P: n/a

This function:

def scp(from_path,to_path,pwd):
"""Copy a file with scp."""
cmd = '/bin/csh -c "scp -q %s %s ; echo XXX"' %(from_path,to_path)
print cmd
child = pexpect.spawn(cmd)
child.expect('Password:')
child.sendline(pwd)
child.expect('XXX')
return child.exitstatus

always returns None. This one:

def scp(from_path,to_path,pwd):
"""Copy a file with scp."""
cmd = 'scp -q %s %s ' %(from_path,to_path)
print cmd
child = pexpect.spawn(cmd)
child.expect('Password:')
child.sendline(pwd)
child.interact()
return child.exitstatus

will return the correct exit status. The big problem is that I would
like to run this function from a cron job. Inside a cron job, interact()
will not work because it is not connected to a real terminal. How can I
get the exit status code? Please help me.

Les

Sep 1 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.