home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 10 / mycd10.iso / progs / tun / dos / emul / emul.arc / TRANSFIL.SH < prev   
Encoding:
Text File  |  1994-07-20  |  2.7 KB  |  128 lines

  1. :
  2. #    @(#) transfile.sh 1.0 94/05/27
  3. #
  4. #    Copyright (C) ESKER the European Software KERnel
  5. #
  6.  
  7. # This shell script example can run on all UNIX system 
  8. # with Bourne Shell interpretor
  9. # The .SEQ file associated with the emulation must be completed by the
  10. # following lines : 
  11. #    \033put%p0%s p 271
  12. #    \033get%p0%s p 272
  13.  
  14. PATH=/bin:/usr/bin:/etc
  15. DOSTOUNIX="DOS->UNIX"
  16. UNIXTODOS="UNIX->DOS"
  17. ASCII="Ascii"
  18. BINARY="Binary"
  19. NONE="None"
  20. QUOTE="'"
  21.  
  22. PromptDirection()
  23.  
  24. {
  25.     while true
  26.     do
  27.         echo "\n\tFILE TRANSFER DIRECTION\n"
  28.         echo "\t1. $DOSTOUNIX"
  29.         echo "\t2. $UNIXTODOS \n\n\n\n"
  30.         echo "\tSelect an option or enter q to quit : \c"
  31.         read answer
  32.         case $answer in
  33.         1)    direction=$DOSTOUNIX
  34.             return 0;;
  35.         2)    direction=$UNIXTODOS
  36.             return 0;;
  37.         [Qq])    return 0;;
  38.         *)    ;;
  39.         esac
  40.     done
  41. }
  42.  
  43. PromptMode()
  44.  
  45. {
  46.     while true
  47.     do
  48.         echo "\n\tFILE TRANSFER Mode\n"
  49.         echo "\t1. $ASCII"
  50.         echo "\t2. $BINARY \n\n\n\n"
  51.         echo "\tSelect an option or enter q to quit : \c"
  52.         read answer
  53.         case $answer in
  54.         1)    mode=$ASCII
  55.             return 0;;
  56.         2)    mode=$BINARY
  57.             return 0;;
  58.         [Qq])    return 0;;
  59.         *)    ;;
  60.         esac
  61.     done
  62. }
  63.  
  64. TransferFile()
  65. {    if [ "$source" = $NONE ]
  66.     then
  67.         echo "Invalid Source File Name!"
  68.         return 0
  69.     fi
  70.     if [ "$direction" = $DOSTOUNIX ]
  71.     then    ESCAPE="\033\033put"
  72.     else    ESCAPE="\033\033get"
  73.     fi
  74.     if [ "$mode" = $BINARY ]
  75.     then    MODE="-b"
  76.     else    MODE=""
  77.     fi
  78.     if [ "$target" = $NONE ]
  79.     then    TARGET=""
  80.     else    TARGET=$target
  81.     fi
  82.     if [ $direction = $DOSTOUNIX ]
  83.     then    SOURCE=`echo $source | dd conv=ucase 2>/dev/null | sed "s#/#\\\\\\\\\\\\\\\\\\\\\\#g"`
  84.         TARGET=$TARGET
  85.     else    SOURCE=$source
  86.         TARGET=`echo $TARGET | dd conv=ucase 2>/dev/null | sed "s#/#\\\\\\\\\\\\\\\\\\\\\\#g"`
  87.     fi
  88.  
  89.     echo "Starting File Transfer..."
  90.     echo "$ESCAPE$QUOTE$MODE $SOURCE $TARGET$QUOTE"
  91.     read answer
  92.     $answer
  93.     echo "Transfer Done..."
  94.     echo "Press Return to Continue"
  95.     read answer
  96. }
  97.  
  98.     direction=$DOSTOUNIX
  99.     source=$NONE
  100.     target=$NONE
  101.     mode="Ascii"
  102.     while true
  103.     do
  104.         DOSUNIX=0
  105.         echo "\n\tFILE TRANSFER\n"
  106.         echo "\t1. Direction [$direction]"
  107.         echo "\t2. Mode [$mode]"
  108.         echo "\t3. Source File Name [$source]"
  109.         echo "\t4. target [$target]\n"
  110.         echo "\t5. Start the File Transfer\n\n\n"
  111.         echo "\tSelect an Option or Enter q to Quit : \c"
  112.         read answer
  113.         case $answer in
  114.         1)    PromptDirection;;
  115.         2)    PromptMode;;
  116.         3)    echo "Warning: You must use the car '/' instead of the car '\\' for the DOS File Name"
  117.             echo "Enter the File Name You Want to Transfer :\c"
  118.             read source;;
  119.         4)    echo "Warning: You must use the car '/' instead of the car '\\' for the DOS File Name"
  120.             echo "Enter the Destination File or Directory :\c"
  121.             read target;;
  122.         5)    TransferFile;;
  123.         [Qq])    exit 0;;
  124.         *)    ;;
  125.         esac
  126.     done
  127. echo "Warning: You must use the car '/' instead of the car '\\' for the DOS File Name"
  128.