S
S
SquareWheel2015-11-23 19:31:43
linux
SquareWheel, 2015-11-23 19:31:43

The bash script does not work, it does not give errors, what could be the problem?

There is a script.

#!/bin/bash
rootFolder=`pwd`
i=0
a=50
while [ "$i" -ge "$a" ]; 
do
$i+1
rsync -avz '-e shh' [email protected]$i.com:/folder1/folder2/  becupfolder$i/folder1/folder2
for $somefolder in `ls -d */ | grep -v '^_'`
do

ssh [email protected]$i.com
echo $somefolder
find $rootFolder/$somefolder/-name "*.waw" -type f -mtime -93 | rsync -avz '-e ssh' $rootFolder/$somefolder/spool/monitor/ [email protected]:$rootFolder/$somefolder/spool/monitor/{}\;
find $rootFolder/$somefolder/-name "*.mp3" -type f -mtime -93 | rsync -avz '-e ssh -p 22n' $rootFolder/$somefolder/spool/monitor/ [email protected]:$rootFolder/$somefolder/spool/monitor/ {}\;
exit
done
done

It, in theory, should bypass a certain number of servers, and rsync to take the contents of the necessary directories, with the exception of one nested one (whose size slightly exceeds the volume of the raid for backups), after which it connects to these servers via ssh, search for files there .waw and .mp3 that are older than a certain time and give them somewhere, where the rest are (in a very perverted way, but I didn’t think of others). However, when run, it doesn't output anything at all, neither command output nor errors.
Perhaps there are some syntax / logical errors in the script, please tell me?
Perhaps this is important, everything lives on debian 8.2.
All ips, folder names, logins, etc. have been changed before this post was written. Just in case.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Azazel PW, 2015-11-24
@SquareWheel

This is exactly what you wanted to write.

i=0
a=50
while ; 
do
let i=$i+1
done

In general, this construction is done through for, bash can do a lot of things :)
for ((i=0; i < 50; i++))
do
done

A
alegzz, 2015-11-23
@alegzz

your script will never be executed, because $i is always less than $a. that is, the condition "as long as $i is greater than $a" is not satisfied at all. well and further: $i+1 is in general what and in what language?
in general, the noble code turned out

N
nirvimel, 2015-11-23
@nirvimel

For debugging, put echo [номер строки]after each line (then remove the most annoying in cycles). -vAdd the first parameter to rsync and ssh calls . Next, you need to consider the output of the script and draw your own conclusions from this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question