Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 14-12-2009
Member
 
Join Date: Jan 2009
Posts: 61
Create Your Own Shell

Hello, I want to create a new shell with certain commands which will support simple commands such as copy, delete, clear and some other. So, any one from you if give me some suggestion then it will be helpful to me. So, please help me to create a shell. I am waiting for your reply.
Reply With Quote
  #2  
Old 14-12-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Create Your Own Shell

HI, I am also searching for same thing which will help me to create my own shell. If you are able to give some basic steps regarding this, then it will be helpful to me. If anyone is having either basic script or steps regarding this, then it will be helpful to me. I will be thankful to you if you provide me some basic information about the same. So, please give me reply which will be helpful to me.
Reply With Quote
  #3  
Old 14-12-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Create Your Own Shell

Hey, basically the shell is a powerful programming environment. And to create a basic shell script you need to follow the steps below:

Step 1 :
Type command below to create a new file
Code: cat > first_script

Step 2:
Now type the following lines:
Code:
echo Your files are
echo today is
datels

Now just press ENTER to move the cursor to a new line and press CTRL-D.

Step 3:
Examine the file :
Code:
cat first_script

Step 4:
Try to run the script by entering its name:
Code:
first_script
It would not run as it is not executable.

Step 5 :
Display the permission of the file by entering:
Code:
ls -la first_script

Step 6:
Type the following command to make first_script executable:
Code:
chmod +X first_script


Step 7 :
To set the new permission, enter:
Code:
ls -l

Step 8 :
Execute the new script by typing its name:
Code:
first_script

Done.
Reply With Quote
  #4  
Old 14-12-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Create Your Own Shell

Hi, I am not having more knowledge about the shell scripting. But, I know how to write a small script. You can make use of the script below to display the date, time, username and current directory.

Code:
echo "Date and time of Today is :"
   date
   echo
   echo "Your username is: `whoami` \\n"
   echo "Your current directory is: \\c"
   pwd
Reply With Quote
  #5  
Old 14-12-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Create Your Own Shell

Basic Psuedocode for a Shell:
For writing any shell script you should be able to write basic pseudocode for a shell.

Code:
int main (int variable, char **argvariable)
     {
	while (1)
	{
		int num;
		char * cmd;
		printPrompt();
	        	cmd= readCommandLine(); 
		cmd = parseCommand(cmd);
		record command in history list (GNU readline history ?)
 		if ( isBuiltInCommand(cmd))
		{
		    	executeBuiltInCommand(cmd);
		} .
		else 
		{		
			num = fork();
		     	if (num == 0)
			{
				executeCommand(cmd); 
			
		     	} 
			else 
			{
			if (isBackgroundJob(cmd))
			{ 
			} 
			else 
			{
				waitpid (num);

			}		
		    }
	        }
     }
Reply With Quote
  #6  
Old 14-12-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Create Your Own Shell

Hi, you can use the script below to crate your own shell. The script below is in C. So, use it.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int num, char *arr[], char *var[])
{
	char one = '\0';
	printf("My first shell ");
	while(one != EOF) {
		one = getchar();
		if(one == '\n')
			printf("My first shell ");
	}
	printf("\n");
	return 0;
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Create Your Own Shell"
Thread Thread Starter Forum Replies Last Post
How can I create shell script which find out who the active, current user is? mANICKAVASAN Windows Software 4 20-10-2010 11:56 AM
Shell terminal for Mac OS X Jensen Ackles Customize Desktop 6 05-05-2010 10:23 AM
Shell script with sed Ameeryan Software Development 5 23-12-2009 02:29 PM
Windows XP "cannot create shell notification icon" error Urjita Windows Software 3 12-02-2009 07:54 PM
Shell - Create a file specifies MACY Tips & Tweaks 0 15-01-2009 09:45 AM


All times are GMT +5.5. The time now is 09:38 PM.