Bash variable substitution in Prodigy

89 views Asked by At

I want to export the results of a Prodigy tagging session through the command db-out. Prodigy is installed in a Google Compute Engine VM, however, I am not the owner of it and for that reason, what I am attempting, looks like this:

# Assume `test1` exists
DB_NAME="test1"
#  `super_user` is Prodigy owner's home directory.
sudo runuser -l super_user -c 'python3 -m prodigy db-out "$DB_NAME" > ./"$DB_NAME".jsonl'

The previous commands should generate a test1.jsonl file, which should be found in the super_user home directory; however, no test1.jsonl is generated. BTW, when those lines are run, no warning or error is displayed.

Nevertheless, when I directly run the following command:

sudo runuser -l super_user -c 'python3 -m prodigy db-out test1 > ./test1.jsonl'

test1.jsonl file is correctly generated, as expected and explained before. Why?

Additional notes / updates:

  1. There is no need into explaining what the runuser or db-out commands are doing. I think the error is more related to a (possibly?) wrong variable substitution from my side, that I am not seeing right now.
1

There are 1 answers

4
David Espinosa On BEST ANSWER

After addressing my attention to this post (which was kindly suggested by Gordon Davidson, and whose revision is highly suggested), I managed to solve my original issue. The corrected code looks like follows:

DB_NAME="test1"
sudo runuser -l super_user -c "python3 -m prodigy db-out $DB_NAME > ./$DB_NAME.jsonl"

Just to make changes clear, they are:

  1. The single quotation marks were replaced by double ones.
  2. The inner double quotation marks were discarded.

Afterwards, the script works as it is supposed to be. If I understand this post correctly, there could be some other valid answers; however this one works for now.

Thank you.