daily pastebin goal
95%
SHARE
TWEET

Untitled

a guest Jul 13th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/ksh
  2.  
  3. echo "
  4. Unrestricted SCP.
  5. "
  6.  
  7. cmd_check() {
  8.     x=0
  9.     for cmd in $@
  10.     do
  11.         which ${cmd} 2>&1 > /dev/null
  12.         if [ $? -ne 0 ]
  13.         then
  14.             echo "${cmd} Not Found. Either install command or add path location to the PATH variable"
  15.             x=$(( ${x} + 1 ))
  16.         fi
  17.     done
  18.     if [ ${x} -ne 0 ]
  19.     then
  20.         exit ${x}
  21.     fi
  22. }
  23.  
  24. cmd_check pax mkfifo ssh rm echo cat
  25.  
  26. if [ $# != 4 ]
  27. then
  28.     echo "--------------------------------------------------------------------------------"
  29.     echo "- This script will copy a directory and all the folders and files.             -"
  30.     echo "- Unlike SCP / tar and gzip there are no file restrictions.                    -"
  31.     echo "- All transfers / and extracts are done on the go, so there is no space        -"
  32.     echo "- requirements to land the data                                                -"
  33.     echo "--------------------------------------------------------------------------------"
  34.     echo " "
  35.     echo "Usage: firo_scp.ksh <dir> <user> <server> <path>"
  36.     echo " "
  37.     exit 1
  38. fi
  39.  
  40. DIR=${1}
  41. DIRNAME=`echo ${DIR} | sed 's/.*\///g'`
  42. USERNAME=${2}
  43. SERVER=${3}
  44. RPATH=${4}
  45. FIFO=./FSCP.$$
  46.  
  47. echo "Making a fifo file"
  48. mkfifo -m 644 ${FIFO}
  49.  
  50. echo "Initiating pax to ${FIFO} fifo for ${DIR}"
  51. pax -wf ${FIFO} -x pax ${DIR} &
  52.  
  53. echo "Making remote fifo file: Authentication Successful should be displayed"
  54. ssh ${USERNAME}@${SERVER} "mkfifo ${RPATH}/${DIRNAME}.ar"
  55.  
  56. echo "catting the local ${FIFO} fifo into remote fifo file: Authentication Successful should be displayed"
  57. cat ${FIFO} | ssh ${USERNAME}@${SERVER} "cat > ${RPATH}/${DIRNAME}.ar" &
  58.  
  59. echo "Initiating remote extract on fifo file: Authentication Successful should be displayed"
  60. ssh ${USERNAME}@${SERVER} "cat ${RPATH}/${DIRNAME}.ar | pax -rxpax"
  61.  
  62. echo "Removing remote fifo file: Authentication Successful should be displayed"
  63. ssh ${USERNAME}@${SERVER} "rm ${RPATH}/${DIRNAME}.ar"
  64.  
  65. echo "Removing local ${FIFO} fifo"
  66. rm ${FIFO}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top