Solved

I'AM PLANNING TO WRITE A SIMPLE SHELL PROGRAM FOR LINUX HOW SHOULD I START?

Posted on 2004-04-13
9
284 Views
Last Modified: 2010-04-22
I'AM PLANNING TO WRITE A SIMPLE SHELL PROGRAM FOR LINUX HOW SHOULD I START?
0
Comment
Question by:ALNMOO
9 Comments
 
LVL 7

Expert Comment

by:leflon
ID: 10811736
hi alnmoo,

could you explain a little bit more of what you like to do?
what shall the prog do? etc.

leflon
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10811743
Duplicate question.

Experts please post here
http:Q_20952053.html
0
 
LVL 7

Author Comment

by:ALNMOO
ID: 10811800
this is my question

Write a special simple command interpreter that takes command(s) and its(their) arguments. This special command interpreter will only have three different cases that need to be addresses in your interpreter program.

1.      If it is a single command, the main process creates a child process to execute the command using exec() family functions. After executing the command, it asks for new command input. (parent wait for child)

2.      If it is a single command and it is to be executed in background, (that is, the command line has a & symbol at end) the interpreter wont wait for its child.

3.      If the command is a multiple background command, (eg. cd lab5 &; ls &) [that is if the background commands are separated by the symbol ; ] then the interpreter creates a number of child processes, equal to the number of commands and executes one after the other in the same order as appear in the command line. Each child process will execute one command using exec family of functions. (parent will not wait for any child. Make sure the first command child process finishes first and then the second starts)
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 45

Expert Comment

by:sunnycoder
ID: 10811829
Membership agreement forbids posting and answering homework questions. Experts here cannot do your homework

http://www.experts-exchange.com/memberAgreement.jsp

Make some efforts on your own and if you are stuck somewhere ask here and we shall be glad to help you out.

sunnycoder
0
 

Expert Comment

by:ray_pro2
ID: 10882549
Dear ALNMOO,

First of all you must understand when to use a shell script and when not to. In general, you use a shell script when:

     1. Customizing your work environment
     2. Automating your daily tasks.
     3. Automating repetitive tasks.
     4. Performing same operations on many files.

A shell script is not executed under the current shell. Instead a new shell is created to execute the script. Thus there is a limit to which a shell script can remain efficient even on being complex. This tells you, that you SHOULD NOT write/use a shell script when:

     1. It is too complex (like your proposed command interpreter).
     2. Requires a high degree of efficiency.
     3. Requires resources that are too many and too costly.

The morale of the story is stop thinking of writting a shell script for creating your special command interpreter - as it is too complex. Write a C proigram insted - which is both easy to write as well gurantee greater efficiency. Availablity of fork() and exec()/exev() functions can make the job much more easy.

If writting a shell program/script is all you are after then there is a simple advice for you : The philosophy of shell scripting/programming is very straightforward. A linux shell executes commands that you type into a terminal. Internally, linux like any other UNIX system treats your terminal as a file, in which the commands are present in the form of character strings. The speciality of the linux (or any UNIX) shell is that, it can not only execute commands from the terminal file, but also from any other file. This is conceptually very similar to the batch file of MS-DOS. But a shell script/program can do much more than just executing commands in a batch. It can also provide programming constructs like if, if-then-else, case-construce, for loop, while loop, until loop, functions and much more.

So just sum up all the commands together that you need to bundle together to perform your task, put them in a text file ( one command in each line), and save it. This is your shell script. Give it execution permissions (use chmod +x filename). And run it -- Thats it.

Hope you make your mind.
                                                 -------------------------------ray_pro2

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12185419
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now