r - Rscript stuck on a system call to python -


i have periodic script running @ background in ubuntu server. if execute in rstudio, works expected. when execute via terminal rscript, gets stuck when calling python script (it isn't always... many times gets stuck there). (i know gets stuck there because when stop rscript, tells me running python script). have chmod 777'ed python script no clue.

this worked until days ago, doesn't know why.

the rscript sentence:

rscript /home/xxx/xxx/scriptserviciobbddhs.r 

the place stops in r code:

outputmacs <- system(ignore.stdout = f, ignore.stderr = t,                     "python3 /home/xxx/xxx/macsprincipal.py 'y.y.y.y' 'user' 'password'", intern = t) 

the python script api mikrotik router. gets stuck when trying read response router. in sentence:

r = select.select([s, sys.stdin], [], [], none) 

i put code in main() of python script:

def main():     s = none     res in socket.getaddrinfo(sys.argv[1], "8728", socket.af_unspec, socket.sock_stream):         af, socktype, proto, canonname, sa = res         try:              s = socket.socket(af, socktype, proto)         except (socket.error, msg):             s = none             continue         try:             s.connect(sa)         except (socket.error, msg):             s.close()             s = none             continue         break     if s none:         print ('could not open socket')         sys.exit(1)      apiros = apiros(s);     apiros.login(sys.argv[2], sys.argv[3]);      inputsentence = ['/ip/hotspot/active/print', '=detail=']     apiros.writesentence(inputsentence)      t_end = time.time() + 2     while time.time() < t_end:         r = select.select([s, sys.stdin], [], [], none)         if s in r[0]:             # read in socket, read sentence             x = apiros.readsentence() 

thank help. script used work when first used in beggining, using crontab. fails.

sergio.

i found possible bug in mikrotik api. problem in sentence

r = select.select([s, sys.stdin], [], [], none) 

i had rewrite omit sys.stdin

r = select.select(s, [], [], 0.0) 

and work have system call via r following arguments:

system(ignore.stdout = f, ignore.stderr = t, "python3 /home/xxx/xxx/macsprincipal.py 'y.y.y.y' 'user' 'password'", intern = t) 

it doesn't work if don't ignore stderr output.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -