Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connecting a c shell (client) script to a server file

Status
Not open for further replies.

FDavid

Technical User
Jul 24, 2003
2
GB
can anyone help with the following scripting problem:
i need these implemented so the client can perform the tasks in the menu on the files.

Client Script
--------------

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 :"
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


--

Server script
--------------

if (($servername[1] == option1)) then
set servername =``
echo "main server is connected" >> ./monitor/serverlock
echo "main server is connected"
endif

if ($argv[1] == 'option4') then
echo -n "enter file to search:"
set datafile = `head -1`
echo -n "enter word or data to search:"
set data = `head -1`
echo ""
echo -n $data
echo -n $datafile
grep -i $data $datafile
echo ""
echo ""
endif

if (($argv[1] == option2)) then
echo -n "enter file to read:"
set datafile = `head -1`
if (($datafile == course)) then
cat course && cat course> ServerMaster1
echo "read the course file" >> ./monitor/courselock
else if (($datafile == student)) then
cat student && cat student > ServerMaster2
echo "read the student file" >> ./monitor/studentlock
else if (($datafile == exam)) then
cat exam && cat exam > ServerMaster3
echo "read the exam file" >> ./monitor/examlock
endif
endif

if ($argv[1] == 'option3') then
echo -n "enter file to sort:"
set datafile = `head -1`
if (-e $datafile) then
sort $datafile
echo -n "server sorted"
end if
endif


I also have .csh files named student, exam and course 25 records in each.


Cheers

 
can anyone help with the following scripting problem:

You haven't given us a problem. What error messages to you get. What exactly are you trying to accomplish?



--
Andy
 
To get things started, when you solicit inputs from users, you should use something like read:

so
echo -n "Enter your option and press :"
should be
1)
echo -n "Enter your option and press :"
read option?

2) read option?"Enter your option and press :"

the variable $option would give you the user input. From there, you can use case statement to continue.

try this first, then post more questions if you need
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top