Tuesday 15 January 2013

shell - exec() PHP cannot wait the response (phpseclib) -


I just try to use the command exec () but it does not work (I use phpseclib). This is my code

  ehock $ ssh-> Exec ("cd testpath; ./display_test.sh 1-s 098888888");  

More results

For example: /testpath/test_displaysub.10912.mml can not open

but When I go with the read (), type () with this code

  $ ssh-> setTimeout (5); $ SSH- & gt; Read (); $ Ssh- & gt; Write ("CD TestPath \ n"); $ SSH- & gt; Read (); $ Ssh- & gt; Write (". / Display_test.sh 1-s 098888888 \ n"); Resonate $ ssh- & gt; Read ();  

This works I want to use the exec () command because it does not use the timeout I think exec () command such error It may happen that it does not wait for the response or leave some commands in that file (./ display_test.sh) because it is in my code

 < Code> sendCommand () {cat $ templateLogout & gt; & Gt; $ {FILE} $ scriptfile & lt; $ {FILE} 1 & gt; $ Procedure file 2 & gt; TMP #led $ processfile to run other} checkTimeout () {timeout = $ (grep "time expired" tmp | wc -l) If [$ timeout -gt 0] then result = "connection is lost." Index_timeout = 1 fi rm tmp} getResult () {Results = egrep "response" $ mmlfile ......... (more)  

When I use exec () This $ processfile is created, but if the $ processfile does not wait to run full, then it checkTimeout () and getResult () Stop doing it It can not do as I think it looks like. If I find it wrong, please tell me.

And please tell me what I will do with this problem if I want to use the command exec () .

Note! I do not really use timeout because my project can input with the file and I do not know how often this process wants to be done in my file

  0988888888 0988888887 0988888886  

And my script is also ./ display_test.sh 1 -f filename \ n

You do not have to use timeout with reading () / writing (). Try instead:

  $ ssh-> Read ('[prompt]'); $ Ssh- & gt; Write ("CD TestPath \ n"); $ SSH- & gt; Read ('[soon]'); $ Ssh- & gt; Write (". / Display_test.sh 1-s 098888888 \ n"); Echo $ ssh-> Read ('[soon]');  

[prompt] is a placeholder - use whatever is your real prompt.

W.r.t $ ssh- & gt; Exec ... may be that $ ssh-> EnablePTY (); $ SSH- & gt; Executive (); Resonate $ ssh- & gt; Read () .


No comments:

Post a Comment