0

I have written a script(test.sh file) to reset mysql and postgres db in docker on System A So when I run test.sh file on System A it works fine

Now I need to run the same file from another System B For this i have to first connect to system A by giving this commands in console

  1. Navigate to folder
  2. enter the system A id test@192.111.1.111
  3. enter password
  4. then run the test.sh file from system B

How can I add all above 3 steps in test.sh file so that I dont have to enter the above 3 steps in console on System B so that I can just run the test.sh file on System B and it will do all the work of connecting tp System A and reset db

echo  "Resetting postgres Database";
docker cp /home/test/Desktop/db_dump.sql db_1:/home
docker exec -it workflow bash -c "npm run schema:drop"
docker exec -it workflow bash -c "npm run cli schema:sync"
docker exec -it db_1 bash -c "PGPASSWORD=test psql -h db -U postgres -d test_db < /home/db_dump.sql"
echo "ProcessEngine Database Resetting";
docker cp /home/test/test/test/test.sql test:/home
docker exec -it test bash  -c "mysql -uroot -ptest -e 'drop database test;'"
docker exec -it test bash -c "mysql -uroot -ptest -e 'create database test;'"
docker exec -it test bash -c "mysql -uroot -ptest -e 'use test; source /home/test.sql;'"

I want to add the connection code of ssh to this code so that i can run it from other system

  1. navigate to folder
  2. ssh test@192.111.1.111
  3. password

how to put this above 3 steps in my code

Goutam
  • 31
  • 2

0 Answers0