3
I have a Shell Script (.sh) and need to automate it. Could someone help me??
This script copies data from a folder and pastes (converting to another format) into another directory, runs a Python script for plotting data, and updates the information obtained on a web page.
To copy and paste files from one folder into another, the script reads the file name, which contains the date entered, and executes the other commands from there.
The data to be copied is from two days ago (since I do not have available the data of the last 24 hours)
The problem is that I need to manually change the date, every day.
I need to find a way to automate this process so that I don’t have to manually update the date.
I need the script to update the date automatically, also run at a certain time of day and return me an error message if I do not find data in the folder to be copied.
I’m new to programming and so I’m having a hard time finding the best way to do this.
Below is the code I’m using:
!/bin/bash
date="2017-11-17"
year=`date +"%Y"`
previous_year=`date +"%Y" -d "-1 year"`
h4=/mnt/raid/CALIPSO/SCRIPTS/
dir=/mnt/raid/CALIPSO/DATA/NETCDF_TEMP/
cd /mnt/raid/CALIPSO/DATA/L1.5/2017/
cp CAL_LID_L15_Exp-Beta-V3-40.${date}T*.hdf /mnt/raid/CALIPSO/DATA/NETCDF_TEMP
for i in ${dir}*.hdf; do ${h4}h4tonccf_nc4 $i; done
python ${h4}CalipsoLatLonTimeLoop_TimTrack.py
#Uploading the data to WEB server
rsync -u -z -v -e "ssh -p 8222" /mnt/raid/CALIPSO/PICS/${year}* [email protected]:/home/www/html/rt/PICS/${year}/
rsync -u -z -v -e "ssh -p 8222" /mnt/raid/CALIPSO/PICS/${previous_year}* [email protected]:/home/www/html/rt/PICS/${previous_year}/
Eventually get a better name for the script (a script called script is like a dog named dog)
– JJoao