Only execute 2nd command on successufl execution of 1st command
Hallo!
I have a script which builds a project and then runs junit tests. However, if the build fails, the junit tests fail with the same error message. Therefore the command which runs the junit tests should only be executed if the build was successful. Do you know a solution to this? |
Use &&
Command1 && command2 Command2 will execute only when command1 executes successfully |
PMP's suggestion works if the failed command sets a non-zero exit status (which almost all do). If it doesn't you need to capture the output and parse it for signs of success or failure
Code:
output="$(command 2>&1)" |
works, thank you!
|
All times are GMT -5. The time now is 01:29 PM. |