script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers script
# 1  
Old 04-29-2008
script

I'm trying to learn unix and was going through some problems when I ran into this questiona about creating a script that will caclulae the suam and average of the scores for the assignments and quizzes after it drops the worst one. this tool will manage the data with each own weight and generate a final grade in the letter format. Also provide the option to send the grade report to user by email. an if then else fi command is expected in the script, same as case in esac and for while loop. Unix `trap` function shall be included to demo how it uses it.
# 2  
Old 04-29-2008
And what's ur question?
# 3  
Old 04-29-2008
stuck

Im not to sure where I'm even supposed to begin with this program. I am a first time user. trying to try to prorams that I'm trying to understand
# 4  
Old 04-29-2008
Sounds like a homework question...

Take the program in pieces. Start simple
# 5  
Old 04-29-2008
I'm going through a unix book that I bought. But I wanted to know if it was possible to see an example to see it I understand it but I have no clue to where to begin
# 6  
Old 04-29-2008
The best thing to start a script is to tell the shell in which shell the script has to run

#!/usr/bin/bash

and then...
# 7  
Old 04-29-2008
i have that so far this is what i have
#!/usr/bin/ksh
#
#export PATH=/bin:/usr/bin
#
#shell variables
PROG=`basename $0`
#
#OutFile=/tmp/$LOGNAME.$PROG
#
#echo "Hi $LOGNAME:\n\tPlease enter scores of assignments (seperate by 'space'): \c"
read input
echo
#
Counter=0
Total=0
Worst=999
cp/dev/null $OutFile
#
for score in $Input
do
#
case "$score" in
[0-9]|[1-9][0-9]|100)
Counter=`expr $Counter +1`
[$score -it$worst] && Worst=$score
Total=`expr $Total + $score`
echo "\tHw-${Counter}: ${score}, Sum: ${Total}, Worst One: $Worst" | tee-a $OutFile
;;
[0-9]|[1-9][0-9]|100)
echo "\tYou enter <$score> which is greater than 100 ==> no! no!!" >&2
exit 10
;;
*)
echo "\tYou enter <$score> which is not a positve number">&2
exit 20
;;
esac
done
#
echo"
$Counter Assignments Total: ${Total}, Worst: $Worst" | tee-a $OutFile
Conter=`expr $Counter -1`
Total=`expr $Total - $Worst`
Average=`expr $Total/$Counter`
echo"
Average is $Average" | tee-a $OutFile
#
echo "Enter the email id to receive tis report: \c"
read Rcptld
if [-n "Rcptld"]; then
mailx-s "CMP-322 Reportcard" $Rcptld <$OutFile
fi
#
exit 0




but Im still missing the if-then-else-fi command, a case-in-esac, and for/while loop, a trap function, and also a function to check input. And that's what I don't know how to do.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question