LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2012, 12:30 PM   #1
javibishop
LQ Newbie
 
Registered: Sep 2012
Posts: 12

Rep: Reputation: Disabled
Bash interpeter


Hello, i am new on linux and i need to do a bash interpeter. I dont have any idea to do it!
Someone can tell me where I would be start?
Thank.
Javier
 
Old 09-14-2012, 12:34 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
... a what?

"Welcome to Linux, but ..." start with first.
 
Old 09-14-2012, 12:40 PM   #3
javibishop
LQ Newbie
 
Registered: Sep 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sundialsvcs View Post
... a what?

"Welcome to Linux, but ..." start with first.
I need to do my own bash interpreter.
I dont know where to start.
I have 1 month to do it.
I need to do that when i open a terminal window my own bash is seted to default bash interpreter and when i write some specifics commands it's be interpreted for it.
Sorry for the english...
 
Old 09-14-2012, 01:01 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
So you need to write a shell. This is not really a trivial task, one month will probably be a too short time.
Anyways, have a look here for something to start with:
http://people.clarkson.edu/~jmatthew/os/homework/shell/
http://linuxgazette.net/111/ramankutty.html
http://youtu.be/J5pUDw3-iRY
 
Old 09-14-2012, 01:08 PM   #5
javibishop
LQ Newbie
 
Registered: Sep 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TobiSGD View Post
So you need to write a shell. This is not really a trivial task, one month will probably be a too short time.
Anyways, have a look here for something to start with:
http://people.clarkson.edu/~jmatthew/os/homework/shell/
http://linuxgazette.net/111/ramankutty.html
http://youtu.be/J5pUDw3-iRY
Something that i forgot to say is that its must be programmed on bash language.
I will read thats pages.
 
Old 09-14-2012, 01:35 PM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Read those pages to get a basic idea how a shell works. If you already know Bash scripting it shouldn't be a problem to adapt that knowledge to it.
If you first have to learn Bash scripting I would think it is impossible to achieve this task in only one month, except may be for a very basic script that just sends the input to a Bash shell and directs the output to stdout.
 
Old 09-14-2012, 01:45 PM   #7
javibishop
LQ Newbie
 
Registered: Sep 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TobiSGD View Post
Read those pages to get a basic idea how a shell works. If you already know Bash scripting it shouldn't be a problem to adapt that knowledge to it.
If you first have to learn Bash scripting I would think it is impossible to achieve this task in only one month, except may be for a very basic script that just sends the input to a Bash shell and directs the output to stdout.

I dont need to do a big shell, only some modules a recognize some commands.
i understand the idea of : http://people.clarkson.edu/~jmatthew/os/homework/shell/ but i dont realize how to set my own sheel script to default bash.
 
Old 09-14-2012, 01:52 PM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
You can use the chsh command to change the default shell for your user. I would recommend to try that on a different user first, especially when you are using a system without root user, like Ubuntu, so that you don't accidentally lock yourself out.
 
Old 09-14-2012, 02:00 PM   #9
cortman
Member
 
Registered: Jan 2012
Location: ZZ9 Plural Z Alpha
Distribution: Crunchbang 11, LFS 7.3, DSL 4.1.10, Lubuntu 12.10, Debian 7
Posts: 219

Rep: Reputation: 43
Looks as though all this is is writing a few custom command scripts and/or aliases?
 
Old 09-14-2012, 02:45 PM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
well implementing a primitive shell in bash isn't that hard; start with commands read and eval

PS: or perhaps what you really want is executing a script automagically whenever you login?

Last edited by NevemTeve; 09-14-2012 at 02:47 PM.
 
Old 09-14-2012, 03:25 PM   #11
javibishop
LQ Newbie
 
Registered: Sep 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
well implementing a primitive shell in bash isn't that hard; start with commands read and eval

PS: or perhaps what you really want is executing a script automagically whenever you login?
I will try to make a pseudocode or something that explain you the idea :

Start ubuntu 1st time.
run some command that install or something my shell and set my shell as default.
exectute some commands that my shell have to interprete(like ls or some process).
run some background proccess to read some config files and do something when this configs change.
write on a file all command that was typed for the user on the prompt.
delegate some command to bash.
unistall my shell and restore the default shell.

I would like to know if there are some file like autoexex.bat of window where i can put some line to tell to linux that i want to set my own shell as default.
is there any body that understand spanish?

Last edited by javibishop; 09-14-2012 at 03:29 PM.
 
Old 09-14-2012, 07:34 PM   #12
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Shells read specific files when they start up. Each shell has its own set/sequence of config files that are read, and which ones are used depends on the type of startup (login vs. non-login). Your shell can similarly configure itself according to your design.

When a user logs in, the default process to be launched is identified in /etc/passwd. Usually, that will be a shell, but it can be anything you want it to be. If you want your own shell to be started on login for a particular user, you use the /etc/passwd file to do so.

--- rod.
 
Old 09-16-2012, 09:36 PM   #13
javibishop
LQ Newbie
 
Registered: Sep 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thanks for all answers! I watched the video on youtube and im starting to try.
Im sure i will post soon.
Javier
 
Old 09-17-2012, 01:38 PM   #14
javibishop
LQ Newbie
 
Registered: Sep 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by javibishop View Post
Thanks for all answers! I watched the video on youtube and im starting to try.
Im sure i will post soon.
Javier

Hello again...i try this steps :
I made a simple script and i modified the passwd file to use for my user my bash script. When i press ctrl + alt + f1(this is an login terminal no?) i put my user and pass and its start to run my bash script.
Is there any way to this script start to run when i press the icon terminal on ubuntu taskbar? I am a little confuse with this two type of terminals. One of this is a non-login terminal and the other is a login terminal?

This is the rigth way to put my bash script as a default bash interpreter?
What i have to do if i want that this script start to running every time that i open the terminal from the taskbar?
Javier

Last edited by javibishop; 09-17-2012 at 01:54 PM.
 
Old 09-17-2012, 03:50 PM   #15
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I have a hard time following the logic of your requirement. If you have a program of some sort that runs whenever the user logs in, does the program allow some way of invoking a second login? What would you expect to happen? It seems a lot like simply running bash from a bash commandline. It can be done, but has very little purpose.

Also, I think the way you are using terminology may be contributing some confusion. You use the the term 'bash interpreter', which seems unusual. When we refer to bash it is normally referred to as a shell. The term 'interpreter' usually implies some kind of programming language, or at least something capable of handling exec's she-bang (#!) syntax. Although bash is technically one of those, the use of the terms bash and interpreter together is uncommon and slightly redundant. Do you mean simply a bash script?

If your question is about running a bash script automatically, then the Bash Reference Manual, 6.2 Bash Startup Files should answer your question. You seem to be asking about 'interactive non-login shells'.


--- rod.

Last edited by theNbomr; 09-17-2012 at 03:52 PM.
 
  


Reply



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
LXer: Share And Discover Cool Bash Tricks With Bash One-Liners LXer Syndicated Linux News 0 01-30-2012 09:50 AM
Bash problem : -bash: [: /bin/bash: unary operator expected J.A.X Linux - Software 1 09-22-2011 05:52 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
BASH -copy stdin to stdout (replace cat) (bash browser) gnashley Programming 4 07-21-2008 01:14 PM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:10 PM.

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
Open Source Consulting | Domain Registration