loop to copy a file from one server to others

loop to copy a file from one server to others

Post by kem.. » Sun, 19 Feb 2006 04:15:15



I am trying to create a loop to copy a file from one server to others:

here is what I got: any suggestions

thanks
Ritchie

v1="pap4"
v2="pap5"
v3="pap6"
count="1"
var="$"v$count
for X in $var
do

   count=`expr $count + 1`
done

 
 
 

loop to copy a file from one server to others

Post by Chris F.A. Johnso » Sun, 19 Feb 2006 04:59:31



> I am trying to create a loop to copy a file from one server to others:

> here is what I got: any suggestions

   The first suggestion is to explain exactly what your problem is.

Quote:> v1="pap4"
> v2="pap5"
> v3="pap6"
> count="1"
> var="$"v$count

   What do you think that does? Print its value and see.

Quote:> for X in $var

   What's the point of X? You don't use it.

> do


   What do you think $var contains?

Quote:>    count=`expr $count + 1`

   What is count for? You don't use it.

Quote:> done

for n in 4 5 6
do
    eval "var=$v$n"

    count=$(( $count + 1 )) ## POSIX; use expr for Bourne
done

    Or:

for var in "$v1" "$v2" "$v3"
do

    count=$(( $count + 1 )) ## POSIX; use expr for Bourne
done

--
   Chris F.A. Johnson, author   |    <http://cfaj.freeshell.org>
   Shell Scripting Recipes:     |  My code in this post, if any,
   A Problem-Solution Approach  |          is released under the
   2005, Apress                 |     GNU General Public Licence

 
 
 

loop to copy a file from one server to others

Post by Chris F.A. Johnso » Sun, 19 Feb 2006 05:15:02




>> I am trying to create a loop to copy a file from one server to others:

>> here is what I got: any suggestions

>    The first suggestion is to explain exactly what your problem is.

>> v1="pap4"
>> v2="pap5"
>> v3="pap6"
>> count="1"
>> var="$"v$count

>    What do you think that does? Print its value and see.

>> for X in $var

>    What's the point of X? You don't use it.

>> do

>    What do you think $var contains?

>>    count=`expr $count + 1`

>    What is count for? You don't use it.

>> done

> for n in 4 5 6
> do
>     eval "var=$v$n"

   Make that:

for n in 1 2 3
do
   eval "var=\$v$n"


>     count=$(( $count + 1 )) ## POSIX; use expr for Bourne
> done

>     Or:

> for var in "$v1" "$v2" "$v3"
> do

>     count=$(( $count + 1 )) ## POSIX; use expr for Bourne
> done

--
   Chris F.A. Johnson, author   |    <http://cfaj.freeshell.org>
   Shell Scripting Recipes:     |  My code in this post, if any,
   A Problem-Solution Approach  |          is released under the
   2005, Apress                 |     GNU General Public Licence
 
 
 

1. break one loop and skip one iteration of outer loop

I am writing a shell script in which I am using 2 while loops. I want to
break out the inner while loop and skip the current iteration of the outer
while loop. Here is a pseudo script. Can anyone suggest a solution.

while [ some condition ]
do
        statement 1
        statement 2
        while [ some condition ]
        do
            if [ some condition ]
            then
#                I want to goto statement 1
#                 how to implement this -- should I put break but this will
merely go to statement 3 #'                which I dont want to execute. In
other words, break out of the inner loop and
#  skip only the current iteration of the outer loop
#
            else
#               Skip the current iteration of the inner while loop
#                I thiink this can be done by continue isn't it?..so here
goes
                  continue
            fi
        done
        statement 3
        statement 4
done

Any help would be appreciated

2. FAT32 formatted drives being read by RedHat Linux?

3. I want to not copy exclude one file when i Copy

4. How to stop GUI from loading

5. socks/tcp server failing (looping) & others

6. Kerberos & tgetent

7. Need help copying files from one server to another.

8. Partitioning problem during installation

9. ksh: Copying files one by one

10. copying data from one file into some other file with VI

11. How can I copy Multipal files(10000) in to one single .txt file

12. Broadcast Sockets, copy one file to n machines???

13. How To Copy Only The Updated/New Files From One Directory To Another?