Re: Script for uploading files - use select or case?
mowgli wrote:
> Firstly, if I use continue to redisplay the list, I
> get an error which says continue can only be used in while and until
> loops.
That's correct. <http://tiswww.case.edu/php/chet/bash/bashref.html#IDX72>
From your code, I suspect that what you actually want is a for loop
<http://tiswww.case.edu/php/chet/bash/bashref.html#IDX31>:
for SERVER in $SERVER1 $SERVER2 $SERVER3
do
echo Now uploading files up files to $SERVER
scp $FILESPATH user@$SERVER:~/mybackup &>> $LOGFILE
# for loop will "continue" for you
done
> Sorry that me being a newbie, it's not very clear to me yet when to
> use select and when to use case.
Don't apologize for being a newbie, everyone had to start somewhere. But you
might want to pick up a book at you local library on basic programming.
'case' and 'select' are both used for completely different things.
case: <http://tiswww.case.edu/php/chet/bash/bashref.html#IDX37>
select: <http://tiswww.case.edu/php/chet/bash/bashref.html#IDX40>
> Also what needs to be done if my username on one server is different
> than on others? And also the ssh port for one server is different?
You will have to use _different_ variables. Have a look at arrays
<http://tiswww.case.edu/php/chet/bash/bashref.html#SEC81>, which could simplify
your code a bit.
HTH.
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE d+(-) s+: a@ C+ ULAHS++$ P- L+>++ E--- W++ N++ o !K w--(+) O- M?>+ V? PS+
PE+(++) Y+ PGP- t+ 5 X R !tv b+ DI(+) D G e++ h---- r+++@ y++++
------END GEEK CODE BLOCK------
|