From: Atropo on
Hi all.

My intend was to copy several files on several serves on differents
dirs.

#!/bin/ksh
#File=$1
sPath=/sourcepath
#sPath=$2
#tPath=$3

for server in "1 2 3 4"
do
echo Server $server

for File in "file1 file2 file3 "
do
while read tPath #dirs where the files will be copy
do
echo scp $sPath/${File} ptuprd(a)app${server}:${tPath}/.

echo scp $sPath/${File} ptuprd(a)ig${server}:${tPath}/.

done<dirs
done
done


it shows

Server 1 2 3 4
scp /sourcepath/file1 file2 file3 ptuprd(a)app1 2 3 4 :/dir1/.
scp /sourcepath/file1 file2 file3 ptuprd(a)app1 2 3 4 :/dir2./.
scp /sourcepath/file1 file2 file3 ptuprd(a)app1 2 3 4 :/dir3/.


the script i've posted is edited, so it may have errors irrelevant to
my concern
From: Chris F.A. Johnson on
On 2010-07-28, Atropo wrote:
> Hi all.
>
> My intend was to copy several files on several serves on differents
> dirs.
>
> #!/bin/ksh
> #File=$1
> sPath=/sourcepath
> #sPath=$2
> #tPath=$3
>
> for server in "1 2 3 4"

How many arguments is "1 2 3 4"?

How many arguments is 1 2 3 4?


> do
> echo Server $server
>
> for File in "file1 file2 file3 "
> do
> while read tPath #dirs where the files will be copy
> do
> echo scp $sPath/${File} ptuprd(a)app${server}:${tPath}/.
>
> echo scp $sPath/${File} ptuprd(a)ig${server}:${tPath}/.
>
> done<dirs
> done
> done
>
>
> it shows
>
> Server 1 2 3 4
> scp /sourcepath/file1 file2 file3 ptuprd(a)app1 2 3 4 :/dir1/.
> scp /sourcepath/file1 file2 file3 ptuprd(a)app1 2 3 4 :/dir2./.
> scp /sourcepath/file1 file2 file3 ptuprd(a)app1 2 3 4 :/dir3/.
>
>
> the script i've posted is edited, so it may have errors irrelevant to
> my concern


--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)

From: hehe2046 on
The problem is in your "for" loop
it should be:
for server in $(echo "1 2 3 4")
or
for server in 1 2 3 4

so
for File in $(echo "file1 file2 file3")
or
for File in file1 file2 file3

If you quoted them, it will be treated as one variable.

Hope that helps,
hehe2046