1

I have "child.interact()" in my code,it runs fine when run normally but when run as cronuser I get the following error..has anyone seen this before and know how to fix it?

  child = pexpect.spawn('ectool --server=commander.company.com login username', logfile=sys.stdout)
  child.expect('Password:')
  child.sendline('password')
  child.interact()

Error:-

  File "/local/mnt/workspace/username/Automation/test.py", line 1453, in <module>
    temp = prism.searchChangeRequestsForGerritInfo(PLProductLine)
  File "/local/mnt/workspace/username/Automation/test.py", line 1094, in searchChangeRequestsForGerritInfo
    lookaheadreset_link = lookaheadreset_ectool(gerrit_id)                                                
  File "/local/mnt/workspace/username/Automation/test.py", line 74, in lookaheadreset_ectool
    child.interact()
  File "/usr/local/lib/python2.7/dist-packages/pexpect/__init__.py", line 1612, in interact
    mode = tty.tcgetattr(self.STDIN_FILENO)
termios.error: (22, 'Invalid argument')
user3654069
  • 345
  • 2
  • 6
  • 14
  • See: http://stackoverflow.com/questions/5496195/cant-open-serial-connection-in-pyserial-termios-error-22-invalid-argument – James Mills Jun 06 '14 at 01:02
  • 1
    @JamesMills - this is hapening only when run as cronjob,so I dont think it has anything to do withpython installation – user3654069 Jun 06 '14 at 01:09
  • My only other thought then is that I'm pretty sure cron jobs do not open up stdin to your subprocess. – James Mills Jun 06 '14 at 01:12
  • @JamesMills - ok..anyother way to fix it? – user3654069 Jun 06 '14 at 01:18
  • There is no way that I know of to fix this. AFAIK STDIN is just simply not available to cron jobs. Where would you read input from? – James Mills Jun 06 '14 at 01:19
  • @JamesMills - I updated the code above..basically if I dont do child.intereact(),am not able to login and the subsequent commands are failing?is there a subsitute for child.interact()? – user3654069 Jun 06 '14 at 01:24
  • I'd say you'd have to find a way to tell cron to open stdin and perhaps give your subprocess (*cron job*) a valid tty/pty. – James Mills Jun 06 '14 at 01:39
  • in my case, I was calling `interact()` to get the exit status (after I knew I reached EOF), but it looks like calling `close(force = False)` also produces a valid exit status. – Andre Holzner Jan 14 '15 at 15:45

0 Answers0