I have a Ruby script that orchestrates a number of other scripts. One of the bash scripts pulls log data from a server, and a ruby script then parses them.
My bash script looks something like this:
#pullLogs.sh
for ((x = $2; x <= $3; x++)); do
# creates a subdirectory for each server number
rsync --progress -rvze ssh name@$ARCHIVE_SERVER:/path/to/log/$logDate.gz $x/
done
for ((x = $2; x <= $3; x++)); do
cd $x
for z in *.gz; do gunzip $z; done
cd ..
done
cd ..
What this script does is pulls logs from a given date, from specified servers. Usually there are ten servers, so the script will pull from server 1, then from server 2, etc etc.
This script works perfectly if I specify the desired date from the command line
./pullLogs.sh desired_date 1 10
successfully pulls all the logs from the desired date from all ten servers.
However, I want to pull all the logs from todays date to some past date, and parse each one. So I use this ruby script:
while upload_day != $DESIRED_DATE do
args = "#{year}#{month}#{day} 1 10"
`bash -c ./#{path_to_pullLogs_sh} #{args}`
`ruby #{name_of_followup_ruby_script}`
upload_day = upload_day.prev_day
end
The ruby script iterates through the correct days and calls the correct bash script (the one given above). However, after running the bash script, it produces an error:
./pullLogs.sh: line 15: ((: x = : syntax error: operand expected (error token is "= ")
./pullLogs.sh: line 21: ((: x = : syntax error: operand expected (error token is "= ")
So when I run it from the console, the loop variables 1 and 10 are good, but when I run it from the ruby script, it finds a problem with my syntax
How can make this work?