0

I am trying to run a few commands through the bash script in mac.

Here is my script

#!/bin/bash

testDirectory='/Users/jxxxx/Desktop/xxxxx/mad_team_training/Trimify/backend-operations/tests/pagination-integration.test.js'
deleteScript='/Users/xxxxx/Desktop/xxxxx/mad_team_training/Trimify/backend-operations/scripts/test-delete-table.sh'
echo "$testDirectory"
cd ../
sls offline start
open -a Terminal.app $deleteScript
RUNNING_PID=$!
kill ${RUNNING_PID}

Problem

  • sls offline start will require mfa and then logs the output continously on terminal( which is needed)
  • But i want to run deleteScript in seperate terminal once sls offline starts but it is not running in the new terminal with current script, somehow it starts only after sls process is killed
  • once delete script is over, kill sls offline start process
Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67
  • Does `sls offline start` background itself? For example, if you run it interactively, does it immediately give you a new shell prompt (and then probably write over it with log output), or does it not let you back into your shell until it's finished (/killed)? (Also, be aware that running `open` does *not* wait for the other program to finish; it starts it, then immediately goes on to the next command). – Gordon Davisson Nov 30 '21 at 04:21
  • sls offline start ask for mfa and then it does not let me back into my shell until it's finished/killed. open does not wait for the other program to finish; it starts it, then immediately goes on to the next command).This is exactly what i am, looking for by the time sls offline ask for mfa and start, i want to run my delete script after 5-10 seconds delay – Jatin Mehrotra Nov 30 '21 at 04:47
  • `expect` could probably do the job. First steps : [background process with expect](https://stackoverflow.com/questions/17916201/background-spawned-process-in-expect), [get pid with expect](https://stackoverflow.com/questions/9260633/how-to-get-the-sub-process-pid-in-the-expect-shell-script-after-spawn) – Aserre Nov 30 '21 at 08:20
  • mfa code is generated from my registered device how will expect work in that case? @Aserre – Jatin Mehrotra Dec 01 '21 at 04:46
  • If I understood correctly : 1) `sls offline start` shows an input asking for your mfa code 2) you take it from your device 3) the program shows you a confirmation line like `mfa code correct` ? – Aserre Dec 01 '21 at 05:54

0 Answers0