I am trying to work with the expect command, everything works well until I try to pipe the results of a command into a Gzip file. Here is the snippet of the bash file:
XYZ=$(expect -c " spawn python log-connector.py -s $strt -e $end -i 600 -a https://server:9000 -u someaccount -f ./conf/firewall-fields2.txt -q ./conf/query.txt -z | gzip >> /data/sources/results-$strt2-$end2.json.gz expect \"Password:\" send \"$pass\r\" interact ") echo "$XYZ"
$start - variable (start date)
$end - variable (end date)
$strt2 - variable (start date with 00:00)
$end2 - variable (end date with 23:59)
$pass - Password entered by the user previously.
If I remove
| gzip >> /data/sources/results-$strt2-$end2.json.gz
from the above it works as expected. When I add it I get the following error:
send: spawn id exp7 not open while executing usage: API [-h] [-s START] [-e END] [-d DAY] [-i INTERVAL] [-a LOGGER] [-l LOGFILE] [-f FIELDS] [-q QUERY] [-o OUTPUT] [-t FORMAT] [-u USER] [-p PASS] [-z] API: error: unrecognized arguments: | gzip >> /data/sources/results-20180604-20180604.json.gz