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 !!
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
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
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
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