shell - How do I merge all the cases into One -


how can merge following 2 case scripts?

script 1

#!/bin/bash ver=0 n="192.168.1.20:/backup/b1" o1="192.168.1.20:/backup/b2"     user="1234" echo "n latrest version"     echo "o1 previous version n-1" echo "o2 previous version n-2" echo -n "which version want backup [n or p]? " read ver     case "$ver" in     (n|o1|o2) scp $user@${!n} . ;;     (*) echo "unknown user"     esac 

above script not working error

cannot stat `1234@': no such file or directory 

script 2

user=0     av="34567"     ma="4568"     im="5678"     mi="12345"     pr="23456"     echo "please select av ma ji im pr"     echo -n "first 2 initial of name eg: [av ma ji im pr]? "     read user     case "$user" in     (av|ma|pr|mi|im) scp ${!user}@$n . ;;     (*) echo "unknown user"     esac 

bit of mix between variables $n , $ver, , value of $o2 not specified.

#!/bin/bash echo "want download [yes no]? " read response [ "$response" = "yes" ] || exit  n="192.168.1.20:/backup/b1" o1="192.168.1.20:/backup/b2" o2="192.168.1.20:/backup/b3" echo "n latest version" echo "o1 previous version n-1" echo "o2 previous version n-2" echo -n "which version want backup [n o1 o2]? " read opt case "$opt" in     n|o1|o2)         server="${!opt}"         ;;     *)         echo "invalid option" >&2         exit 1         ;; esac  av="34567" ma="4568" im="5678" mi="12345" pr="23456" echo -n "enter initials [av ma im mi pr]: " read opt case "$opt" in     av|ma|im|mi|pr)         user="${!opt}"         ;;     *)         echo "unknown user" >&2         exit 1         ;; esac  scp "${user}@${server}" . 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -