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 8839333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:12:58+00:00 2026-06-14T10:12:58+00:00

me and my hair-brained ideas again… i am building a mailserver install script and

  • 0

me and my hair-brained ideas again…
i am building a mailserver install script and i have hit on something i want to ask before i do just to cover my bases. i know how to use php with the shell_exec command and proc_open commands to run shell commands like sudo and apt-get but what i do not know is how do i do an install that asks for user input? my example is part of the installation calls for mysql server and when you install it via the command line it asks for the password of the admin user for mysql to be set. i have my script get that info from the user in a form and can pass the data along to other pages but how do i do pass it to the shell?

What i know how to do:

$mySql_password = $_POST['mysql_password'];
$output = shell_exec("apt-get -y install <package-id>");

or even:

$mySql_password = $_POST['mysql_password'];
$output = shell_exec("apt-get --force-yes install <package-id>");

how would i go about passing the password to it after i have it set as a variable?
keep in mind that this script is going to be run from the desktop of the server(if they have a desktop) or via a web browser and the script will have a self destruct mode at the end to erase the install script to prevent someone from forgetting about it. ssl is also going to be recommended as pre-install checklist.

  • 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-14T10:13:00+00:00Added an answer on June 14, 2026 at 10:13 am

    After looking around a bit (google “Unattended MySQL Install” or something among these lines), something that should help you is DEBIAN_FRONTEND=noninteractive.

    Try this to install without password and set it afterwards :

    <?php
    
    shell_exec('echo '.$rootPassword.' | DEBIAN_FRONTEND=noninteractive sudo -S aptitude install -q -y mysql;
    mysql -uroot -e "UPDATE mysql.user SET password=PASSWORD("'.$mysqlPassword.'") WHERE user='root'; FLUSH PRIVILEGES;');
    
    ?>
    

    Alternatively, debconf-set-selections should allow you to set a default password so mysql is directly installed with it.

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

Sidebar

Related Questions

I'm tearing my hair out. Apparently you can't just do something like class Ranch<T>
I am pulling my hair here. I want to link 2 subform fields to
Really ripping my hair out on this one. I have a JAAS Authentication Provider
Am tearing my hair out here. Have read many examples which describe how to
I'm tearing my hair out over something that may very well be very simple,
I'm tearing my hair out on this one so thought I'd ask over here.
I'm pulling my hair out (once again), trying to find a way to read
Again pulling my hair out due to some Flex/AS3 weirdness. The following code does
So after pulling my hair out for 30 minutes, I have decided to come
I'm pulling my hair out over this one. I want to get all contents

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.