Skip to content

Instantly share code, notes, and snippets.

@gvieira18
Created June 2, 2024 20:22
Show Gist options
  • Save gvieira18/7fbee596cb2113a0765ac4a74ac8bab0 to your computer and use it in GitHub Desktop.
Save gvieira18/7fbee596cb2113a0765ac4a74ac8bab0 to your computer and use it in GitHub Desktop.
Ah shit, here we go again
#!/usr/bin/env bash
# Name of the container
CONTAINER_NAME=""
# Command to run inside the container
COMMAND="cqlsh -e \"USE carepet\""
# Run the command inside the container
docker exec -it "$CONTAINER_NAME" bash -c "$COMMAND"
EXIT_CODE=$?
# Print the exit code of the docker exec command
echo "The exit code of the docker exec command is: $EXIT_CODE"
# Optionally, handle the exit code
if [ $EXIT_CODE -ne 0 ]; then
echo "Command failed with exit code $EXIT_CODE"
# Perform any error handling or recovery here
else
echo "Command succeeded"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment