Hello Everyone,
I have been trying to complete a shell script where, I need to increment the date depending on the file (depending on the date) availability on the remote server.
i.e.
Basically, I will be passing a counter (like parameter 1 or 2 or 3 or 4).
First I will check for the availability of 7days file on the remote server.
If the file is not available then depending on the counter, the script should increment the date and check for the files (zip & non-zip) on the remote server.
For example:
Day=`date -d'1 week ago' +%Y%m%d`
bd=$Day
If the script is running on 10/14/2011, then I am calculating the Day value as 10/07/2011 and the file name as
file='fixed.out.'$bd.'gz' i.e. file='fixed.out.20111007.'gz'
ssh remote_cmp 'ls -ltr /home/brittany/$file' --> to check whether the file is available on the remote server.
if [[ $? -ne 0 ]]
then
<1.If the counter (parameter) is 1, I need to increment the date to +1 i.e. the new date would be 10/08/2011 and
then check if the file is available (check for zip file and non zip file) on the remote host.
2. If the counter is 2, I need to increment the date to +2 i.e. the new data would be 10/09/2011 and
then check if the file is available (check for zip file and non zip file) on the remote host.
3. ..... so on until counter is 4 >
Could someone please share the thoughts how can I increment the date, i.e. set the new date to the variable and
then check for the files on the remote host.
Really appreciate your thoughts.