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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:23:40+00:00 2026-06-15T07:23:40+00:00

Imagine I have a script.sh on my server that asks for your name. You

  • 0

Imagine I have a script.sh on my server that asks for your name. You run the script and it says:

what is your name?

then you input your name and it prints:

hello name! 

Is it possible, using php exec, to run such a script? That is to exec the script and somehow answer the different questions it could have?

Hope I am clear. What I am really trying to do is automate the “git pull” command from our dev server but it keeps asking for a username/password. I know I could use ssh certificate login to avoid that but my question still stands. Can I use exec() and answer future questions from the script.

  • 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-15T07:23:41+00:00Added an answer on June 15, 2026 at 7:23 am

    It’s worth noting that the better solution in your case is to use SSH keys for authentication. But, you might be able to pull this off with PHP Expect.

    ini_set("expect.timeout", -1);
    ini_set("expect.loguser", "Off");
    
    $stream = expect_popen("git pull");
    
    while (true) {
        switch (expect_expectl ($stream, array (
                array ("username:", USERNAME),
                array ("password:", PASSWORD),
        ))) {
            case USERNAME:
                fwrite ($stream, "usename\n");
                break;
            case PASSWORD:
                fwrite ($stream, "secret\n");
                break;
    
            case EXP_TIMEOUT:
            case EXP_EOF:
                break 2;
    
            default:
                die ("Error has occurred!\n");
        }
    }
    
    fclose ($stream);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's imagine we have some script 'm12' (I've just invented this name) that runs
Imagine we have a server side application that generates streaming content full of JavaScript
Let's imagine I have a bash script, where I call this: bash -c some_command
Imagine I have following table: NAME DATE OTHER_CONTANT 'A' '2012-06-05' 'baz' 'A' '2012-06-04' 'bar'
Imagine I have a cell that I want to be red if the value
Imagine you have an entity that has some relations with other entities and you
I have asp.net application that use forms authentication to control access. Let's imagine we
I have a SQL Server 2008 database which contains data that I need to
I have created a script that analyzes a set of raw data and converts
I'm writing an automation script on a production server that, among other things, needs

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.