Sponsored Content
Top Forums Shell Programming and Scripting Something is wrong with this switch( case statement. Post 302469425 by snakemasterAK on Saturday 6th of November 2010 01:56:01 AM
Old 11-06-2010
Question Something is wrong with this switch( case statement.

I started writing a script to save the files from a camera I got the other day, which mounts in /Volumes , and I got into it and started building this menu. The only problem is that the switch case is coming up as a syntax error at the parenthesis after a case. Here is the code:
Code:
while :
 do
    clear
    echo "-----Menu for Camera Save Script-----"
    echo " Main Menu "
    echo "-------------------------------------"
    echo "[1] Save to dir: Todays date/time"
    echo "[2] Save files custom dir: "
    echo "[5] Exit/Stop"
    echo "======================="
    echo -n "Enter your menu choice [1,2,5]: "
    read yourch
    case "$yourch" in
      1)
        mkdir $HOME/Pictures/`date +%d_%m_%H%M`;
        mv /Volumes/SpyCam/_REC/100MEDIA/* $HOME/Pictures/`date +%d_%m_%H%M`;
        ;;
      2)
	echo "Enter Name of New Dir: ";
        read `newdir`;
        mkdir $HOME/Pictures/$newdir;
        mv /Volumes/SpyCam/_REC/100MEDIA/* $HOME/Pictures/$newdir;
        ;;
      5)
        exit 0;
        ;;
      *)
        echo "No try 1, 2 or 5.";
        echo "Press a key. . .";
        read;
        ;;
  esac
done

As you can see, it displays the menu, and once it does that, it waits for two options, one for an auto named directory with the date and time, or one for a custom named directory. It won't work though. it says there is an unexpected parentheses at 1).
Thanks for anyone who tries to figure this out.
oh, also, I am executing within bash.

Last edited by Franklin52; 11-06-2010 at 08:13 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using getopt with a switch statement

hi all, i have been trying to get a script working that can take in more than one option using getopt. But for some reason, even when i type in a covered option, it skips directly to my error message of "no match." Any ideas of what might be wrong? set - 'getopt frd*: $*' for i in $* do... (6 Replies)
Discussion started by: gammarays
6 Replies

2. Shell Programming and Scripting

Ignore case sensitive in Case Switch

In a Case switch, how to ignore case sensitive in the test: e.g. case "$field" in "TEST) action1;; *) action2;; esac How to go in action1 in case of $field = TEST , or Test , or test or .... without enumerating all possibilities... Thanks,... (1 Reply)
Discussion started by: annelisa
1 Replies

3. Shell Programming and Scripting

Help needed in switch case handling in UNIX

Hi, In below code, i am expecting the output has Bye Bye But i am getting has Bye Hi Code: #!/usr/bin/bash var="Hi" cat txt.txt | while read var1 do next="Bye" case $var in Hi) (1 Reply)
Discussion started by: Balamani
1 Replies

4. Shell Programming and Scripting

Help needed in Switch Case

Hi Experts team, i wish to use switch case in unix. my req is case $code in 1111) echo "1111" 1112) echo "1112" *) echo "default" esac see eventhough for particular case 1111 , it is always execute the default statement *), if i code like this. How can handle... (2 Replies)
Discussion started by: spkandy
2 Replies

5. Shell Programming and Scripting

Tcl switch statement

I am just learning Tcl and there are few things about it that is perplexing me. I have a question about the switch statement. Why are these two switch statements giving me different results? $ cat test_switch.tcl #!/usr/bin/tcl set foo "abc" switch abc a - b {puts "No. 1"} $foo {puts... (2 Replies)
Discussion started by: SFNYC
2 Replies

6. Shell Programming and Scripting

Example of switch case in Bash

can anyone post a sample code for a switch case in shell (1 Reply)
Discussion started by: sumit the cool
1 Replies

7. Shell Programming and Scripting

Switch Case not working

My switch case is not working properly. When I press 6 or 'r' it prints out all the names of the project and the error message. #!/bin/bash while true; do read -p "Enter project number (1/2/3/10/20/30):" menu #grabs the informations of the project number and stores it into a menu... (1 Reply)
Discussion started by: Rapcher
1 Replies

8. Shell Programming and Scripting

Why result is wrong here ? whether break statement is wrong ?

Hi ! all I am just trying to check range in my datafile pls tell me why its resulting wrong admin@IEEE:~/Desktop$ cat test.txt 0 28.4 5 28.4 10 28.4 15 28.5 20 28.5 25 28.6 30 28.6 35 28.7 40 28.7 45 28.7 50 28.8 55 28.8 60 28.8 65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies

9. Programming

Passing arguments from command line to switch case statement in C

Hi Am pretty new to C.. Am trying to pass the arguments from command line and use them in switch case statement.. i have tried the following #include <stdlib.h> main(int argc, char* argv) { int num=0; if ( argc == 2 ) num = argv; printf("%d is the num value",num); switch ( num ) ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

10. Shell Programming and Scripting

Why does it not work (Switch Case)?

Hi there, I'm trying to run a simple script,but i'm always getting this error Syntax error: word unexpected (expecting "in")I have searched many sites,like this,but i dont get it,it looks good so far,but wont work,maybe someone can help me. Here is the Script #!/bin/bash while : do... (6 Replies)
Discussion started by: JustAnUser
6 Replies
IM-SWITCH(8)						      System Manager's Manual						      IM-SWITCH(8)

NAME
im-switch - set up input method for X Window SYNOPSIS
im-switch [-v][-z ll_CC] -s inputmethodname im-switch [-v][-z ll_CC] -c im-switch [-v][-z ll_CC] -a im-switch [-v][-z ll_CC] -l im-switch -h im-switch DESCRIPTION
This manual page very briefly documents the im-switch command. The im-switch command provides the framework to configure and to switch the input method on X Window System depending on the locale. This input method is the essential mechanism for Japanese, Chinese and Korean (CJK) languages to enter their non-ASCII native characters. Some input methods such as IBus, SCIM, and uim support not only one of these CJK languages but support almost all languages simultaneously by dynamically switching keyboard modes with GUI. The most desirable input method is provided as the configurable system wide default using Debian alternatives mechanism with /etc/alterna- tives/xinput-ll_CC link. The X start up code sources /etc/X11/Xsession.d/90im-switch which read the configuration file and activates the input method. The user configuration files and links are located in ~/.xinput.d/ . The system configuration files and links are located in /etc/X11/xinit/xin- put.d/ . This structure ensures to have different input methods to be installed side-by-side. im-switch understands the following options: -v Display verbose message during execution. -z ll_CC Set up the input method for X run under ll_CC locale (ISO 639 / ISO 3188). When changing the fallback default for all locales, use all_ALL as the quasi-locale value here. The setup by this all_ALL does not override specific setups. -s inputmethodname Set up the input method to use inputmethodname. -c Configure the input method with menu. (Under X, this uses GUI.) -a Reset the input method to the system default. -l List the input method configuration. -h Print a help message to the standard output and exit. When the im-switch command is invoked without any command arguments, it functions as -c option case. This is meant to be used by the GUI menu. SEE ALSO
update-alternatives(8) /usr/share/doc/im-switch/README.Debian /etc/X11/xinit/xinput.d/default AUTHOR
This manual page was written by Osamu Aoki <osamu@debian.org>, for the Debian GNU/Linux system (but may be used by others). IM-SWITCH(8)
All times are GMT -4. The time now is 09:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy