Sponsored Content
Top Forums Shell Programming and Scripting Something is wrong with this switch( case statement. Post 302469506 by snakemasterAK on Saturday 6th of November 2010 05:35:20 PM
Old 11-06-2010
Text editor

No, I used nano, although I did copy and paste some of it into TextEdit before moving it back along.
here is the actual error message:
/bin/cammenu: line 14: syntax error near unexpected token `)'
/bin/cammenu: line 14: ` 1)'

---------- Post updated at 01:35 PM ---------- Previous update was at 01:01 PM ----------

alright. I redid all of the spacing and finally managed to get it to work. here it is fixed...
I am still making other modifications, but the case thing works now. thanks for the idea.
code:
Code:
#!/bin/bash
while :
do
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


Last edited by snakemasterAK; 11-06-2010 at 06:41 PM.. Reason: I found the Code tag...
 

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
SHTOOL-ECHO.TMP(1)					      GNU Portable Shell Tool						SHTOOL-ECHO.TMP(1)

NAME
shtool-echo - GNU shtool echo(1) extensional command SYNOPSIS
shtool echo [-n|--newline] [-e|--expand] string DESCRIPTION
shtool echo is an echo(1) style command which prints string to stdout and optionally provides special expansion constructs (terminal bold mode, environment details, date, etc) and newline control. The trick of this command is that it provides a portable -n option and hides the gory details needed to find out the environment details under option -e. OPTIONS
The following command line options are available. -n, --newline By default, output is written to stdout followed by a "newline" (ASCII character 0x0a). If option -n is used, this newline character is omitted. -e, --expand If option -e is used, string can contain special "%x" constructs which are expanded before the output is written. Currently the following constructs are recognized: %B switch terminal mode to bold display mode. %b switch terminal mode back to normal display mode. %u the current user name. %U the current user id (numerical). %g the current group name. %G the current group id (numerical). %h the current hostname (without any domain extension). %d the current domain name. %D the current day of the month. %M the current month (numerical). %m the current month name. %Y the current year. EXAMPLE
# shell script shtool echo -n -e "Enter your name [%B%u%b]: "; read name shtool echo -e "Your Email address might be %u@%h%d" shtool echo -e "The current date is %D-%m-%Y" HISTORY
The GNU shtool echo command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1998 for Website META Language (WML) under the name buildinfo. It was later taken over into GNU shtool. SEE ALSO
shtool(1), echo(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-ECHO.TMP(1)
All times are GMT -4. The time now is 12:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy