I have a config_file.yml file like this:
sample:
sql: "select * from dbname.tableName where sampleDate>='2018-07-20';"
config: {'hosts': [!!python/tuple ['192.162.0.10', 3001]]}
sample2:
sql: "select * from dbname.tableName where sampleDate<='2016-05-25';"
config: {'hosts': [!!python/tuple ['190.160.0.10', 3002]]}
My python code is:
data_config = yaml.load(config_file)
for dataset, config in data_config.items():
args = [config]
cmd = ['./execute_something.sh']
cmd.extend(args)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()
execute_something.sh:
#!/bin/bash
echo $1
data_config=$1
echo $data_config
So basically I want to pass {'sql': "select * from dbname.tableName where sampleDate>='2018-07-20';", config: {'hosts': [!!python/tuple ['190.160.0.10', 3002]]}}
this entire string as an argument to the shell script.
Problem:
1) select *
ends up listing all files in the current directory, instead of being passed entirely as a string
2) even if I pass a simple string say args="hi"
it still won't work!
I don't understand what I am missing here. Kindly help. Thanks!