Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8098861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:12:38+00:00 2026-06-05T22:12:38+00:00

I am attempting to install an application using phpseclib (using apt-get) and want to

  • 0

I am attempting to install an application using phpseclib (using apt-get) and want to handle the different output results I could receive… however I am unsure how to get it working. I currently have the following:

$first = $ssh->read('root@DMZ-Server:~#');
$ssh->write("sudo apt-get install emacs\n");
echo "<br />";
echo "sudo apt-get install emacs";
echo str_repeat(' ',1024*64);
if ($unexpected_output = $ssh->read('root@DMZ-Server:~#')){
  echo "<pre>$unexpected_output</pre>";
  echo str_repeat(' ',1024*64);
}   elseif ($continue = $ssh->read('Do you want to continue [Y/n]?')){
    echo "<pre>$continue</pre>";
    echo str_repeat(' ',1024*64);
    $ssh->write("Y\n");
    $continue_end = $ssh->read('root@DMZ-Server:~#');
    echo "<pre>$continue_end</pre>";
    echo str_repeat(' ',1024*64);
} 

This if loop only works with the first “if”… That is if there is unexpected output (You go back to the shell without being asked “Do you want to continue”, which means already install, etc) then this script will work just fine.

But if the application is not installed it will never go to the elseif loop. I’m pretty sure the reason is because the first ssh->read will continue until php times out, waiting for that result… how do I write it so that it will look at both options simultaneously, and pick the correct one.

I am thinking about using CASE for this, but am not sure how to write that…

There also might be a better way to do this using phpseclib… but not sure how to do that.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:12:39+00:00Added an answer on June 5, 2026 at 10:12 pm

    Why don’t you instead change how you call apt-get to apt-get install -y emacs so it doesn’t prompt yes or no? You may also want to use -q so it doesn’t print progress.

    See apt-get(8)

    The problem with your solution is that $ssh->read wait until the given pattern is found.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many times I cannot get my application to install on the emulator. I receive
I am attempting to install an application. During compilation it fails with the following
I'm attempting to install the following Haskell package on Windows using Cygwin: HaskellCuda You
I'm attempting to install the 'mysql2' gem on my production server using Capistrano. I
I'm attempting to do a bundle update on my rails application but I get
I am attempting to install PostgreSQL 9 (postgresql-9.0.3-1-windows.exe) on my WinXP machine and get
I am attempting to bundle up a Python application using py2exe 0.6.9 and Python
I am attempting to install SynEdit_D2010 into my Delphi 2010 IDE, and I get
Im attempting to install the Mail_Mbox-0.6.3 package as i need to use the classes
I am attempting to install Ruby 1.9.3 on Mac OS X Lion, same method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.