If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > help with shell

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-07-05, 12:09
elisa1001 elisa1001 is offline
Registered User
 
Join Date: Nov 2005
Posts: 2
help with shell

can any one help me with this shell problem please

The
shell will loop continuously to accept user commands; it will terminate when "exit" is
entered. The command line prompt must contain the pathname of the current directory.
Internal commands
The shell must support the following internal commands:
First: /ayed/ > cd [[<pathname>] <directory>]
Change the current default directory to <directory>. If the <directory> is not present,
report the current directory. If the directory does not exist an appropriate error message
should be reported.
e.g.
/ayed/> cd project or /ayed/> cd /ayed/project
Second: History
Display a history of the last 10 commands executed on the shell.
Third : exit
Quit the shell.
Other than that the program shall read, parse and interpret the command and call the
appropriate command from the existing shell.
For simplicity sake, assume that only the following commands can be input to the shell:
1. ls
2. ls -l
3. date
4. pico <filename>
5. history
6. man <subject>
7. diff <filename1> <filename2>
8. set
9. who
10. rlogin <host-name>
The shell should fork a new process for each executed command.

Program Skeleton:
while(! EOF) {
read input
handle regular expressions; // parse the next command by the user.
if(built-in command) {
execute command; continue; }
if(child = fork()) { // create a child to run command
child = wait(&res);
}
else { // command is run here
exec(command, argc, argv0, argv1, …)
}
}
Reply With Quote
  #2 (permalink)  
Old 11-08-05, 10:33
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool


This looks like a HOMEWORK assignment.
Have you tried coding something on your own?
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 11-09-05, 12:18
yrs yrs is offline
Registered User
 
Join Date: Nov 2005
Posts: 2
sudo could be can be a simple option just give the user access to the list of commands through sudoers.
Reply With Quote
  #4 (permalink)  
Old 11-11-05, 14:59
elisa1001 elisa1001 is offline
Registered User
 
Join Date: Nov 2005
Posts: 2
Red face i tryed

well i realy tryed to solve it
this is what i thought of but i just dont know what to do next
so any one can help me and tell me what to do next
i mean i dont know what to fork
can any one help me please
#include <iostream>



void push (char input);
bool IsFull (void);
bool IsEmpty (void);
void pop (void);
void history (void);









using namespace ::std;

char input;
int max=10;
int front=-1;
char *queue;
int rear=-1;
void main(){



cin>> input;

while(input != 'e')


{

if(input=='h'){
push(input);
history();
}

}
if(input=='e')

cout<<"exit"<<endl;





}



void push (char input) {

if (IsFull())
{
pop();
queue[++rear]=input;
}

else
queue[++rear]=input;

}


void pop (void){

if (IsEmpty())
cout<<"Is Empty"<<endl;

else

queue[++front];

}



bool IsFull (void){

if (rear==max-1 && front==-1)
return true;

else
return false;

}




bool IsEmpty (void){

if (rear== front)
return true;

else
return false;

}



void history (void){

while (!IsEmpty())

{
cout<<queue[rear]<<endl;
rear--;
}
}
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On