carlosx2 Posted March 4, 2015 Share Posted March 4, 2015 Hello, I have the following problem. I am trying to automate the process of installing a control panel like zpanel. I have already done this with vestacp and it installs perfectly but i have one problem and that is that i need to out put when it is completed with installing. The problem is that i need php to wait to execute the last line till the the rest has been executed. Let me show you my code tha tis installing the control panel on the remote server. elseif ($softname == 'zpanel') { $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); //$ssh->write("yum update -y\n"); //$ssh->setTimeout(20); //$ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("yum install mc nano screen wget -y\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("screen\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("wget https://raw.github.com/zpanel/installers/master/install/CentOS-6_4/10_1_1.sh\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("chmod +x 10_1_1.sh\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("./10_1_1.sh\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("y\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("8\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("34\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("1\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write(" \n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write(" \n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("y\n"); $ssh->setTimeout(5); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("n\n"); $ssh->setTimeout(250); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX); $ssh->write("cat /root/passwords.txt\n"); $ssh->setTimeout(20); $zpanelpass= $ssh->read('/.*@.*[$|#]|.*[P|p]assword.*/', NET_SSH2_READ_REGEX); $zpanelpasses = (explode(":",$zpanelpass)); $ssh->write("reboot\n"); mysql_query ("INSERT INTO bloksinstalls (userid, bl_id, name, paths, version, uniid, mysqlpass, mysqluser) VALUES ('$bl_userid','$bl_productid', '$softname', '$paths', '$version', '$uniid', '$zpanelpasses[3]', 'root')"); echo "<div class='col-lg-12 text-center'> <h4 class='success-header'>Copy the following information to a safe place.</h4> </div> <div class='col-md-12 text-center success-subheader text-primary'>To login into your control panel use the following user and password:</div> <div class='col-md-6 text-right success-login'> Username: <strong class='text-success'>zadmin</strong><br></div> <div class='col-md-6 text-left success-login'> Password: <strong class='text-success'>". $zpanelpasses[1]."</strong><br></div> <div class='col-md-12 text-center success-tlink text-primary'>Click the link to access your control panel:</div> <div class='col-md-12 text-center success-link'><a class='text-success' href='https://". $ip."' target='blank'>https://". $ip."</a> <i class='text-success fa fa-arrow-circle-right'></i></div> "; } So as you can see i try to use settimeout, but i also have tried to use sleep to control when the script continues with the rest of the script. But when i see the timeout or sleep too high the ajax on the front keeps loading as it seems it is not getting any output in the data. As soon as ajax get the out it will start the success function(data). I am not sure i might have my problems in my ajax which look like this $(document).ready(function() { $('#eml').focus(); $('#instbtn').click(function() { var a = $('#eml').val(); var b = $('#pw').val(); $('.blinstbtn').fadeToggle(300); $('.insttext').fadeToggle(300); $('#loadingimage').show(); $('#loadtext').show(); $.ajax({ type:"POST", url: "templates/cloudblok/php/functions.php", data: {soft : soft, username: username , password: password, ip : ip, bl_productid: bl_productid, bl_userid: bl_userid, paths : paths, version : version, uniid : uniid,}, success: function(data) { $('#loadtext').hide(); $('#loadingimage').hide(); $('#compinfo').show(); $('#sshcall').html(data); }//END success_ajax1 }); //END ajax() #1 }); //END mybutt.click() }); //END $(document).ready() I also have tried to make a while and do while loop in my php page. The while loop will also for a certain file and only when it would turn out yes it would continue the code. Of course that didn't work. I am out of solutions here. Maybe some one can help me or point me in the right direction so i can get more control over the time of the execution of the script. thanks Quote Link to comment https://forums.phpfreaks.com/topic/295106-php-installing-control-panel-through-the-command-line-execution-time-problem/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.