I am developing a pre-prod server for a Symfony2 app
I made a little hook script to update all of my git repositories which contain a Symfony app.
# ...
# Save old database
DATABASE_NAME=`YAML Parser Command` 'app/config/parameters.yml' database_name
TODAY=`date +"%Y-%m-%d-%H:%M:%S"`
logger -t "Update website Symfony2" "Save SQL in $TODAY.sql"
mysqldump $DATABASE_NAME > sqlSave/$TODAY.sql 2>&1 | logger -t "Update website Symfony2"
# Update database with doctrine
php app/console doctrine:schema:update --force 2>&1 | logger -t "Update website Symfony2"
# ...
How can I have access to the database name on this script ?
My server is on Debian. Is there a package to parse YAML?
You can parse yaml/json file directly in your shell/bash with niet.
Easy to install and easy to use:
$ pip install -U niet
Consider the following example:
$ cat dump.yaml
foo:
bar:
key: value
baz:
key: value
tags:
- one
- two
You can parse this example file like this:
$ niet dump.yaml foo.bar.key
value
$ for el in $(niet dump.yaml foo.tags); do echo ${el}; done
one
two
Niet have a good integration with shell and others bash like.
Niet yaml parser documentation, source code, and samples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With