gustavok Posted September 4, 2014 Share Posted September 4, 2014 (edited) Hi, I want to use a series of terminal commands, first to open the terminal ( if needed ), change the user ( log in as another user ), enter in a folder and execute a command to start a SQL server and then log out and close the terminal window ( if needed, maybe I can do it without opening it ). After that I want to do the same to stop the server, but following the logic is the same script just changing the start to stop. # Manually Start PostgreSQL ## su as user "postgres" and run server: su postgres # type the password ( if possible do it automatically ) cd /Library/PostgreSQL/9.0/bin/ ./pg_ctl -D /Library/PostgreSQL/9.0/data/ start # then logout exit # close the terminal window Anyway thanks for the attention ! Edited September 4, 2014 by gustavok Link to comment
jdfwarrior Posted September 5, 2014 Share Posted September 5, 2014 Hi, I want to use a series of terminal commands, first to open the terminal ( if needed ), change the user ( log in as another user ), enter in a folder and execute a command to start a SQL server and then log out and close the terminal window ( if needed, maybe I can do it without opening it ). After that I want to do the same to stop the server, but following the logic is the same script just changing the start to stop. # Manually Start PostgreSQL ## su as user "postgres" and run server: su postgres # type the password ( if possible do it automatically ) cd /Library/PostgreSQL/9.0/bin/ ./pg_ctl -D /Library/PostgreSQL/9.0/data/ start # then logout exit # close the terminal window Anyway thanks for the attention ! The trickiest part of this will be switching users because of the prompt for password. Would it be possible to edit the sudoers file and give the current user the ability to launch Postgres? That would make that part easier. Link to comment
rice.shawn Posted September 8, 2014 Share Posted September 8, 2014 You could also play around with "expect" in order to deal with the password. See more here. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now