[Ilugc] scp query

  • From: suraj@xxxxxxxxxxx (Suraj Kumar)
  • Date: Mon Jul 26 10:51:40 2004

anuradha wrote: 
,----
| That is,  can I copy  a file  in machine A  to machine B  from machine
| C. If yes,please send me the command.
`----

Unfortunately, no. However you can write a script like this:

#!/bin/bash

# arguments this script takes
# 1: name of machine (A)
# 2: file(s) in machine (A)
# 3: name of machine (B)
# 4: target directory in machine (B)

if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]; then
   ssh $1 "tar -cz $2 -f -" | ssh $3 "tar -xz -C $4 -f -"
else
   echo "usage: $0 src_machine src_filespec dest_machine dest_filespec
fi

Note: 
  1: of course, I'm assuming this is GNU tar
  2: I haven't tested this script. please fix if any issues ;)

cheers,

  -Suraj

-- 
,-----------------[http://www.symonds.net/~suraj/]---o
| The word raga comes from the word color.
`------------------------------[suraj@xxxxxxxxxxx]---o

Other related posts: