php+expect+ros

Hi, everybody!
I’ve got some problem running such thing:

  1. expect script, that login to ros and reset queue counters
  2. php script, that run expect script

expect script work correctly if started from shell as /usr/local/bin/expect script
expect script work correctly even if it is started as sudo -u www php -r ‘shell_exec(/usr/local/bin/expect script);’
BUT
when it started from web page ros stop responding after authorisation
expect started with -d flag output is following

expect version 5.43.0 argv[0] = /usr/local/bin/expect argv[1] = -d argv[2] = expect.script set argc 0 set argv0 “expect.script” set argv “” executing commands from command file expect.script spawn /bin/sh parent: waiting for sync byte parent: telling child to go ahead parent: now unsynchronized from child spawn: returns {16300} expect: does “” (spawn_id exp4) match glob pattern "$ "? no $ expect: does "$ " (spawn_id exp4) match glob pattern "$ "? yes expect: set expect_out(0,string) "$ " expect: set expect_out(spawn_id) “exp4” expect: set expect_out(buffer) "$ " send: sending “ssh login@...\r” to { exp4 } expect: does “” (spawn_id exp4) match glob pattern "assword: "? no ssh login@...* expect: does “ssh login@...\r\r\n” (spawn_id exp4) match glob pattern "assword: "? no login@...'s password: expect: does "ssh login@...\r\r\nlogin@...'s password: " (spawn_id exp4) match glob pattern "assword: "? yes expect: set expect_out(0,string) "ssh login@...\r\r\nlogin@...'s password: " expect: set expect_out(spawn_id) “exp4” expect: set expect_out(buffer) "ssh login@...\r\r\nlogin@...'s password: " send: sending “pass\r” to { exp4 } expect: does “” (spawn_id exp4) match glob pattern “] >"? no expect: does “\r\n” (spawn_id exp4) match glob pattern "] >”? no expect: timed out send: sending “/queue tree reset-counters\r” to { exp4 } expect: does “\r\n” (spawn_id exp4) match glob pattern “] >"? no /queue tree reset-counters expect: does “\r\n/queue tree reset-counters\r\n” (spawn_id exp4) match glob pattern "] >”? no /queue? expect: does “\r\n/queue tree reset-counters\r\n/queue?\r\n” (spawn_id exp4) match glob pattern "] >"? no expect: timed out send: sending “/quit\r” to { exp4 } send: sending “exit\r” to { exp4 } /quit exit Connection to ...* closed. $ expect: timed out write() failed to write anything - will sleep(1) and retry…

As i understand problem is right after authorisation or with it because if i send wrong password, then expect got “authorisation failed”, but if password is right, then nothing is shown (except \r\n) neither on login, nor in ros log.
“and i wonder” (c)

any ideas?

P.S. Btw, specific problem i’m trying to solve with these scripts is resetting queue counters from web. Maybe you can suggest another solutions (except for ssh key authorisation)?

Tankyouverymuch everybody for viewing my post :wink:
Problem is solved!
Ros could not determine terminal type, when expect is started from web page.
And the solution is “TERM=xterm /usr/local/bin/expect script”.

I think you can contact with http://www.confighelp.net .. they help me a lot.