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

  • Home
  • SEARCH
  • 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 7081379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:54:49+00:00 2026-05-28T06:54:49+00:00

Im trying to write a bash script that executes several commands as different users

  • 0

Im trying to write a bash script that executes several commands as different users to automate an install process.

At one point I have

su gpadmin
gpperfmon_install --enable --password password --port 5432
y  
gpstar
y 

The su gpadmin is run as root, and once it is run the script stops until I exit gpadmin and return as root.

How would one switch to a new user without halting the script?

Sorry for my ignorance, I attempted to google but found nothing that worked.
Any help would be greatly appreciated.

  • 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-05-28T06:54:50+00:00Added an answer on May 28, 2026 at 6:54 am

    You need to use the -c option to su in order for it to run a command and then exit. With the options you have given to su, it will run gpadmin’s default shell, which will block until the shell has exited. Judging by the code you already have, it appears that gpperfmon_install is an interactive application, which is another issue. Sometimes you can use a here document, but in other cases you will need to use expect.

    su gpadmin -c 'gpperfmon_install --enable --password password --port 5432 << EOF
    y
    gpstar
    y
    EOF'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a bash script that will process a list of files
I am trying to write a bash or PHP script that will execute a
I'm trying to write a bash script that wraps whatever the user wants to
I'm trying to write a bash script that can edit itself. The line of
I'm trying to write a bash script that will let me download multiple web
I am trying to write a simple bash script that will search for files
I'm trying to write a simple bash script that accepts all arguments and interprets
I am trying to write a bash script to automatically mount a volume that
I'm trying to write a shell script that will make several targets into several
I'm trying to write a bash script that will download all of the youtube

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.