Computing.Net > Forums > Unix > Need help in Program C

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need help in Program C

Reply to Message Icon

Name: Dorwin6
Date: April 8, 2008 at 04:40:08 Pacific
OS: Linux/Unix
CPU/Ram: E6600 / 4GB
Product: Asus
Comment:

Hi guys,

I was given a script from my teacher to do make some changes. However, I have no knowledge of program C. I would appreciate if anyone are able to advice me what is the error on the scripts.

The script is
echo " select any option to execute:"
echo " c or C: To connect Client to Server"
echo " r or R: To make a read request"
echo " s or S: I want to sort data"
echo " g or G: Look for a certain word in a file"
echo " e or E: quit"
echo -n "Enter your option and press <Enter>:"
set selection = `head -1`

switch ("$selection")
case [cC]:
echo -n "enter server name"
set servername = `head -1`
find $servername
breaksw

case [rR]:

cp
echo -n "enter server file to read content"
set serverfile = `head -1`
breaksw

case [sS]:

sort
echo -n "enter server file to sort"
set serverfile1 = `head -1`
breaksw

case [qQ]:

exit 0

breaksw

default:

case [qQ]:

exit 0

breaksw

default:
echo " wrong option."
exit 1
breaksw
endsw
exit 0

I have change the script to executable.
When I run it, It shows

darren@linux:~$ ./clientlooker1
select any option to execute:
c or C: To connect Client to Server
r or R: To make a read request
s or S: I want to sort data
g or G: Look for a certain word in a file
e or E: quit
Enter your option and press <Enter>:4
./clientlooker1: line 10: syntax error near unexpected token `"$selection"'
./clientlooker1: line 10: ` switch ("$selection")'
darren@linux:~$

If someone can advice me with this, that would be greatly appreciated.

Many thanks,
Darren




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Need help in Program C

need help on Unix program www.computing.net/answers/unix/need-help-on-unix-program/4936.html

Need help writing a program www.computing.net/answers/unix/need-help-writing-a-program-/5479.html

need help with finger command. www.computing.net/answers/unix/need-help-with-finger-command/4284.html