Question

you are to create a simple “shell” for Linux systems. A shell is a command interpreter...

you are to create a simple “shell” for Linux systems. A shell is a
command interpreter whose main function is to get and execute the next user-specified command.

Required Tasks
You must write the shell in C/C++ for Linux systems, and the shell must have the following
functionalities (or features):

1. can use command chdir to change to a given directory.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

First lets create a shell in Linux. Follow the below steps.

$ vi simpleshell.sh (Note: here vi is an editor to create a file, simpleshell.sh is shell name)

now write the C program in the shell as shown below

#include<stdio.h>
#include<unistd.h>
int main()
{
char s[100];
  
// printing current working directory
printf("%s\n", getcwd(s, 100));
  
// using the command
chdir("..");
  
// printing current working directory
printf("%s\n", getcwd(s, 100));
  
// after chdir is executed
return 0;
}

Now press Esc and type :wq to save the file.

So now, the shellscript simpleshell.sh is ready.

Now to run the shell script, use the command below

$ ./simpleshell.sh ( This runs the shell script and the chdir() changes the dir)

Add a comment
Know the answer?
Add Answer to:
you are to create a simple “shell” for Linux systems. A shell is a command interpreter...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You are required to develop a simple Linux shell in C language “shell.c". The shell has...

    You are required to develop a simple Linux shell in C language “shell.c". The shell has to perform the following requirements: - - The shell prompt is “"myshell>". - Run commands either from current directory or from “/bin" directory using the "exec" system call. - Support output redirection like "command> filename" using "dup" system call. Note: save the output of the comment in the (filename). - Implement the “history shell command to list the last ten commands entered so far....

  • Write a C program that implements a simple shell. The shell takes a user command as...

    Write a C program that implements a simple shell. The shell takes a user command as input and execute the command. When a shell is started, it should take user command, execute it and display the output.

  • Boot into your Linux partition (or open Linux in a VirtualBox VM). You will create a...

    Boot into your Linux partition (or open Linux in a VirtualBox VM). You will create a new directory in your home directory called csci2020u/lab02. We’ll add this folder to the Git repositories. Use the following steps to complete this lab: 1. Change into the csci2020u directory 2. Make a new directory, called lab02 3. Add the lab02 directory to Git 4. In the lab02 directory, create the directory structure used by Gradle (the files will be initially empty, you can...

  • Project 1: Implementing a Shell 1 Overview In this individual project you will have to design...

    Project 1: Implementing a Shell 1 Overview In this individual project you will have to design and implement a simple shell command interpreter called mysh. The basic function of a shell is to accept lines of text as input and execute programs in response. The shell must be able to execute built-in commands in a process different from the one executing mysh. 2 Requirements When first started, your shell should initialize any necessary data structures and then enter a loop...

  • UNIX Write and run a simple shell script name mymenu that creates a simple command menu....

    UNIX Write and run a simple shell script name mymenu that creates a simple command menu. The script should present menu items (see below), prompts the user for a selection, and then executes the appropriate command selected. [Submit your script and the results of a test case for a, b, c, and d selections]     COMMAND MENU a. Current date and time b. Name of the working directory c. Contents of the working directory Enter a, b, or c:

  • Creating a Shell Interface Using Java This project consists of modifying a Java program so that...

    Creating a Shell Interface Using Java This project consists of modifying a Java program so that it serves as a shell interface that accepts user commands and then executes each command in a separate process external to the Java virtual machine. Overview A shell interface provides the user with a prompt, after which the user enters the next command. The example below illustrates the prompt jsh> and the user’s next command: cat Prog.java. This command displays the file Prog.java on...

  • Using Kali Linux, the Windows Linux Sub-System, or another Debian based Linux distribution, perform the following...

    Using Kali Linux, the Windows Linux Sub-System, or another Debian based Linux distribution, perform the following tasks based on the Linux Fundamentals lecture. For this lab, take screenshots for all major steps completed to illustrate that each task was successfully completed the same method as would be used for other labs). Tasks: 1. Create a new user named Billy Bob using the command linter face 2. Add Billy Bob to the sudoers group 3. Update and upgrade your Linux distribution...

  • Overview Writing in the C language, implement a very basic shell, called smash. In this project,...

    Overview Writing in the C language, implement a very basic shell, called smash. In this project, we will work on processing strings and using the appropriate system calls. Build System setup Before we can start writing code we need to get our build system all setup. This will involve writing a very simple makefile. You should leverage your Makefile project for this part of the assignment! Write a Makefile that provides the three targets listed below all - The default...

  • please write down the code Thank you. Write a simple shell that is similar to this: while(1 //repeat forever //display prompt on screen type_prompt )i read_command ( command, parameters); // read inp...

    please write down the code Thank you. Write a simple shell that is similar to this: while(1 //repeat forever //display prompt on screen type_prompt )i read_command ( command, parameters); // read input from terminal if ( fork) 0) // parent //wait for child wait NULL elset execve (commamd, parameters, 0 // execute command but contains enough code that it actually works so you can test it. For simplicity, you may assume that all commands are in the directory /bin Write...

  • This is done in Linux terminal. Modify the .bashrc file using command line which would add...

    This is done in Linux terminal. Modify the .bashrc file using command line which would add the following functionality to your shell upon opening a new terminal: 1. Alias called “fc” (short for “folder contents) invoking the command “ls -lah”B. Welcome message “This is demo number 7” C. Variable “semester” being equal to “Winter 2020” and print the value on screen 2. Create any directory of your choice and add it to PATH variable. 3. Show an example of local...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT