LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-11-2011, 04:12 AM   #1
parmishr
LQ Newbie
 
Registered: Sep 2011
Posts: 9

Rep: Reputation: Disabled
Create a user defined shell in Ubuntuusing c program


I am using ubuntu flavour of linux operating system i wanted to know how we can create an user defined shell through c program
 
Old 09-11-2011, 04:21 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Write one? Why do you want to write a new shell? You're really going need to give more details about what you want to do.
 
Old 09-11-2011, 04:28 AM   #3
parmishr
LQ Newbie
 
Registered: Sep 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
i am givin the following c code so that the $ prompt which comes default gets changed but my code is not working

#include<stdlib.h>
int main()
{
while(1)
{
system("PS1=\"FTS>\" bash" );
}
return 0;
}

i want FTS> to come instead of the $ prompt
 
Old 09-11-2011, 04:32 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Why on Earth are you trying to write a C program for this? There's no need to write a program just to change your prompt. This has nothing to do with creating a new shell.

You just set the PS1 variable and it will change the prompt for your current shell. If you want a permanent change, then put it in your ~/.bashrc.
 
Old 09-11-2011, 04:34 AM   #5
parmishr
LQ Newbie
 
Registered: Sep 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
i want to implement more things in that code thats why i want to write c program on that,
can u please help me out with it.....
 
Old 09-11-2011, 04:35 AM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
What exactly do you want to do? If you want to create a new shell, then look at the source code for Bash, Tcsh, or any other shell.
 
Old 09-11-2011, 04:35 AM   #7
parmishr
LQ Newbie
 
Registered: Sep 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
can u please tell me how to create a new user defined shell in c program..
 
Old 09-11-2011, 04:35 AM   #8
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Please write words out in full.
 
Old 09-11-2011, 04:36 AM   #9
parmishr
LQ Newbie
 
Registered: Sep 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
sir im extremly new to this os i have very limited information regarding all this commands if u can help then it would be really great.
 
Old 09-11-2011, 04:37 AM   #10
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You still haven't explained exactly what you want to do. Why do you want to create a new shell? I suspect that's not what you want to do, but you're not exactly helping us to understand what it is you want.

Please write words out in full and use punctuation, because it's difficult to read posts without it.
 
Old 09-11-2011, 04:41 AM   #11
parmishr
LQ Newbie
 
Registered: Sep 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
OK,
Sir let me start from the beginning, i want to create my own shell in which i can execute my own user defined commands.
since I'm new to this OS i don't have enough knowledge of the terminology used here.
 
Old 09-11-2011, 04:42 AM   #12
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
What exactly do you mean by "user defined commands"? Are they just programs you've written? Why do you need a new shell for that? Again, you should probably look at how, e.g. Bash works..
 
Old 09-11-2011, 04:47 AM   #13
parmishr
LQ Newbie
 
Registered: Sep 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
user defined command means fr eg: for ls command i want to give myls which will work like "ls" but in my own shell which i have created.
i want to do this so as to learn creation of shell and want to create my own commands.
 
Old 09-11-2011, 04:52 AM   #14
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello parmishr and Welcome to LinuxQuestions,

I'm under the same impression as Nylex that you are complicating things way to much. Why would you reinvent the wheel? If it's only for learning purposes, great! But if you want to learn from scratch on how to 'create' your own shell, why don't you, as already told by Nylex, download the source of one of the shells available, for example Bash, investigate that source code, adapt it to your needs and compile. Then you would have 'your own commands' in a shell. Another way to have your 'user-defined commands' is to work with aliases.

@Nylex: if the cake means what I think it means... Happy Birthday!

Kind regards,

Eric
 
1 members found this post helpful.
Old 09-11-2011, 04:58 AM   #15
parmishr
LQ Newbie
 
Registered: Sep 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
ok i will do that also i mentioned one code above can you just correct it so that i can get the FTS> prompt.
that will be a big help
regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
user defined input in shell script ovaisalam Linux - Newbie 4 12-08-2010 07:44 AM
Create user-defined chains of accounting rules spoonpower Linux - Security 1 02-05-2007 09:19 AM
user defined shell commands ashley_31 Linux - Software 11 05-15-2006 04:27 AM
How to launch a program as a defined user at startup. Linux.tar.gz Linux - Software 2 03-20-2005 12:28 PM


All times are GMT -5. The time now is 06:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration