Shell script automation using case statement

Hi,

I'm trying to write a shell script that has a menu and then dependant on the selection, will automate some samba file transfer.

The problem is when I run the code without the case statement it runs fine. but when I put the case statement in the only way I can get the code to run is to remove the "SMB_1" entries but then the samba commands are no longer automated. Help please !!

Code is below :

#!/bin/sh
#
################
#Deployment script
################

echo " Please select one of the following :

    1.      Upload from dev platform
    2.      End

    Please enter choice : "

read sel

case $sel in
1) echo "going to upload from dev ..."
/opt/samba/bin/smbclient //devsyst1/packages$ -Wdevsyst11 -Uadministrator << SMB_1
tar c syst_update.tar NewSyst
exit
SMB_1
gzip syst_update.tar
;;
*) echo "gone"
;;
esac

Any ideas ?:confused:

why not do an actual menu system. maby this will help ya.

this seems to work for me.

PS3='Your selection? '
select option in 'Send_to_Dev' quit; do
        if [[ $option == 'Send_to_Dev' ]]; then
                cat << EOF
GOOD
awsome
super cool
EOF

        else
                echo BAD
                exit
        fi
done

Or use the smbtar utility packaged with the samba suite...

Tried the menu code but kept getting an error :

unexpected do

Any ideas ?

Also can't find smbtar in samba suite ... I've got a standard Solaris install of it, if that makes any difference.

Cheers ....

The select statement is a ksh thing. It won't work with sh.

Maybe you can try this simple menu (this is origanally for AIX)

#
# Main loop
#
while [ 1 ]
do
cat <<-EOT

    1.  start programm 1
    2.  start programm 2
    3.  start programm 3



    type exit to quit

EOT

    echo "        Enter your choice: \\c"
    read choice
    case $choice in
            1\)      start\_programm_1.sh
                    ;;
            2\)      start\_programm_2.sh
                    ;;
            3\)      start\_programm_3.sh
                    ;;
            exit\)   clear
                    echo "\\nEnd of session...\\n"
                    exit 0
                    ;;
            *\)
                    echo "\\007\\007\\007\\c"
                    echo "\\n        This choice does not exist, please choose another one ! \\c"
                    sleep 2
                    ;;
    esac

done

my bad i thought i had included the shell. here this works now.

#!/bin/ksh

PS3='Your selection? '
select option in 'Send_to_Dev' quit; do
        if [[ $option == 'Send_to_Dev' ]]; then
                cat << EOF
GOOD
awsome
super cool
EOF

        else
                echo BAD
                exit
        fi
done