#!/bin/ksh clear choice=null while [ $choice != "q" ] do clear echo " Host to Host Copy Utility " echo " ------------------------- " echo " " echo " a) Host to Host File copy utility " echo " b) Host to Host Directory copy " echo " c) Host to Network File copy " echo " q) Quit " echo " ------------------------- " echo " " echo " Enter utility (a, b or q): \c" read choice echo " " case $choice in [aA]) echo "# This utility is only enabled in a trusted host environment." echo "# Be sure that the destination host has the appropriate /.rhosts" echo "# or /etc/hosts.equiv entry." echo "---------------------------------------------------------------" echo " " echo "Enter destination host: \c" read host echo "Enter desinataion directory: \c" read dest echo "Enter local source file (absolute): \c" read file echo "Checking $host's availibility..." ping $host if [ $? = "0" ] then echo "Copying files to $host's $dest directory." sleep 2 rcp $file $host:$dest 2> /dev/cosole if [ $? = "0" ] then echo "File Transfer complete!" else echo "Error Return Code $?" echo "Check your source and destination!" echo "----------------------------------" echo "File transfer was UNSUCCESSFUL!" sleep 3 fi sleep 3 else echo "$host is not a valid ip on the network. Check the /etc/hosts file!" sleep 3 fi sleep 3 ;; [bB]) echo "# This utility is only enabled in a trusted host environment." echo "# Be sure that the destination host has the appropriate /.rhosts" echo "# or /etc/hosts.equiv entry." echo "---------------------------------------------------------------" echo "" echo "Enter destenation host: \c" read host echo " " for x in $(cat /etc/passwd | cut -f1 -d:) do rsh $host test -d /export/home/$x if [ $? = 1 ] then echo "$x's home directory already exists on $host" sleep 2 else echo " " echo "Copying $x's home directory to" echo " " rsh $host mkdir /export/home/$x sleep 3 rcp /export/home/$x/* $host:/export/home/$x rsh $host chown -R $x:staff /export/home/$x fi done ;; [cC]) echo "# This utility is only enabled in a trusted host environment." echo "# Be sure that the destination host has the appropriate /.rhosts" echo "# or /etc/hosts.equiv entry." echo "---------------------------------------------------------------" echo "" echo "Enter file to be pushed: \c" read file echo "Enter destination directory: \c" read dest for f in $(cat /etc/hosts | tr -s " " | cut -f1 -d " ") do rsh $f test -d $dest if [ $? = 0 ] then rcp $file $f:$dest echo "The file $file has been pushed to $f..." sleep 1 else echo "Error pushing $file to machine $f" echo "Check destination directory on remote machine!" sleep 1 fi done ;; [*]) echo "WRONG OPTION!" sleep 3 ;; esac done