Homework Help.

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Homework Help.
# 1  
Old 02-01-2011
Homework Help.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Hello,

My name is Jordan and studying at the New Bulgarian University in Sofiya. This is my homework but can not write the last two questions.

5. Why command exit, placed in a shell script follows:
(statements; exit)
will not finish the script? How do you overcome it.

6. Write a script that calculates the factorial of the number receiving
as an argument. Suggest variant control arguments.


2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

New Bulgarian University, Sofiya. Teacher is N. Gadjev. Faculty number F49086

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by Scott; 02-01-2011 at 03:56 PM.. Reason: Please use the correct template when posting in the homework forum
# 2  
Old 02-01-2011
Quote:
(statements; exit)
The brackets cause the two commands to be executed in a subshell. Therefore the "exit" will only exit the subshell not the calling shell.

We need to tell the calling program that we want to exit. One way is to exit with a non-zero status and test that value in the calling script.
Code:
(statements; exit 2) ; REPLY=$?
if [ $REPLY -eq 2 ]
then
     exit
fi

# 3  
Old 02-01-2011
simple factorial script:
Code:
#! /bin/ksh
n=$1
i=0
fact=1
while ((i<n)) ; do
        ((i=i+1))
        ((fact=fact*i))
done
echo $fact
exit 0

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Homework Help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 2. Relevant commands, code, scripts, algorithms: Write a command to display lines ending with the... (1 Reply)
Discussion started by: elh009
1 Replies

2. Homework & Coursework Questions

Homework

plz i need code to search about numbers like this : 962785785698 962795565488 962785321565 962777321684 962795979515 i need code to detect just numbers start with "96278" i need it in awk !! thanks (1 Reply)
Discussion started by: eyad mohammad
1 Replies

3. Homework & Coursework Questions

Please help me with my homework!!!

A shell script is a script written for the shell, or command line interpreter, of an operating system. Typical operations performed by shell scripts include file manipulation, program execution, printing text etc. Shell : In computing, a shell is a piece of software that provides an interface for... (1 Reply)
Discussion started by: ubun
1 Replies

4. Shell Programming and Scripting

Homework

1. Write a shell script to print the file names of all files having .txt extension of a given directory after converting to uppercase letters. The input (directory name) should be given as command line argument. The script will also check whether sufficient arguments are passed or not and whether... (1 Reply)
Discussion started by: aninda1989
1 Replies

5. Homework & Coursework Questions

Need some help with my homework

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hi, since I'm relatively new to Unix I need some help. I've installed FreeBSD 8 on a virtual machine and I've done... (4 Replies)
Discussion started by: iLeeT777
4 Replies

6. UNIX for Dummies Questions & Answers

Homework :(

1. You have a very large file, named 'ColMe', tab-delimited, you are asked to process. You are told that each line in 'ColMe' has 7 columns, and that the values in the 5th column are integers. Using shell functions (and standard LINUX/UNIX filters), indicate how you would verify that these... (1 Reply)
Discussion started by: mb774
1 Replies

7. Post Here to Contact Site Administrators and Moderators

Homework?

https://www.unix.com/shell-programming-scripting/113946-scripts.html Looks like an assignment or homework to me, does it to you? (5 Replies)
Discussion started by: TonyFullerMalv
5 Replies
Login or Register to Ask a Question