LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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


Closed Thread
  Search this Thread
Old 10-12-2006, 03:29 PM   #16
the2k
Member
 
Registered: Dec 2005
Location: Devon - UK
Distribution: Suse - Desktop, Arch - Laptop, Centos - Server and whatever I fancy on the other machine ;)
Posts: 59

Rep: Reputation: 15

Quote:
Originally Posted by 9GB
The link is not working i suppose ...
Are you sure it was the correct link?

just thought i should let you know, the first part of the thread was started over 3 years ago. someone has brought it back up from the depths.
 
Old 10-12-2006, 11:14 PM   #17
9GB
LQ Newbie
 
Registered: Oct 2006
Location: Pakistan
Posts: 5

Rep: Reputation: 0
Ooops!

I didnt saw the date ... sorry
 
Old 10-12-2006, 11:32 PM   #18
Francinoman
LQ Newbie
 
Registered: Sep 2006
Posts: 13

Rep: Reputation: 0
And that someone was me... just seemed easier than creating a new thread. At least this way is could be helpful to anyone else because they have serveral examples to work off
 
Old 10-13-2006, 01:09 AM   #19
9GB
LQ Newbie
 
Registered: Oct 2006
Location: Pakistan
Posts: 5

Rep: Reputation: 0
Yes and I got this thread when I was googling ...
 
Old 10-14-2006, 02:19 AM   #20
con
Member
 
Registered: Jul 2005
Location: Finland
Distribution: Slackware
Posts: 213

Rep: Reputation: 30
Quote:
is it strange that i am enjoying this project?
Nah,its not strange..youre are learning new stuff and that is fun...keep it up! <thumbs up!>

Nice code BTW!
 
Old 10-15-2006, 07:45 PM   #21
Francinoman
LQ Newbie
 
Registered: Sep 2006
Posts: 13

Rep: Reputation: 0
Cheers for the feedback mate!

Im up to adding redirection of input and output, and piping into the shell... the first thing I am going to work on is the redirection... which has me a little stumped at the moment. If anyone can offer advice as to how I could redirect the output/input from the execvp() function that would be nice :P

Last edited by Francinoman; 10-15-2006 at 09:24 PM.
 
Old 10-31-2006, 04:12 PM   #22
studentlb
Member
 
Registered: Oct 2006
Posts: 53

Rep: Reputation: 15
Hello,

Well Francinoman can u tell us what happened with the code if possible?
Thanks in advance
 
Old 11-01-2006, 12:45 AM   #23
Francinoman
LQ Newbie
 
Registered: Sep 2006
Posts: 13

Rep: Reputation: 0
Ok, well i didnt get to finish my shell before the due date of the project. I handed the project in yesterday, but it wasnt done how i wanted it to be so i was a bit dissapointed! But I will keep working on it anyway just out of interest and will post my updates here.

For now I am at work at the moment so I will paste the current version of the shell source code when I get home for all to look at and tear apart!!

Just a MASSIVE thanks to anyone on these forums that have helped me out along the way! I hope my source code can help people (or at least get them in the right track)
 
Old 11-01-2006, 05:27 AM   #24
studentlb
Member
 
Registered: Oct 2006
Posts: 53

Rep: Reputation: 15
Thanks a lot Francinoman for ur quick reply
Well, to be honest with you i need an intensive help if possible
i m taking an operating course and till now the teacher explained Fork(),execv()
and suddenly gave us a project
what he said is the following:
u ve to write a minishell and wrote the following on the board:

cmd1 [<input][|cmd2}[>output]
the [] are optional

that's all!!! he didn't explain !!

Unfortunatley i m not able to figure out what i ve to do !!! :s
i did lot of research and studied the fork () execv() 1000 times

After lot of searches, i figured out that u are workinf on the same project.
So please can u help me or at least can u tell me what should i do so i try to do it ??

thanks in advance
 
Old 11-01-2006, 11:56 PM   #25
Francinoman
LQ Newbie
 
Registered: Sep 2006
Posts: 13

Rep: Reputation: 0
Sorry mate, i forgot to post my code!!! I will get onto that tonight! It was a hectic day at work.

From the sounds of it you basically need to write a C program that does the following (as earlier in the thread)

1)Read a command from the user
2)Break the command up into a number of different strings (So extract the command, then any arguements that are supplied with the command) using strtok()
3)Create a fork
4)Inside the fork process, execute the command and the args using some thing like execvp(The_acutal_command_here, an_array_of_args_with_the_command_as_the_first_entry_of_the_array[])
5)Once the command has executed, clear all variables and repeat from step 1.

An early example of my code is on page 2 of this thread... its like the 3rd post on this page. it will probably be a good place for you to start. Maybe start from there?

Hope this helps ya!

*EDIT* I think my example code is on the 1st page of this thread actually...near the end of page 1
 
Old 11-02-2006, 03:27 AM   #26
studentlb
Member
 
Registered: Oct 2006
Posts: 53

Rep: Reputation: 15
Thanks a Lot Francinoman for all ur help,appreciated !
I will try to start but i ll appreciate if u provide me with more help :$
Thanks again
 
Old 11-02-2006, 05:49 PM   #27
Francinoman
LQ Newbie
 
Registered: Sep 2006
Posts: 13

Rep: Reputation: 0
Ok, well for now, i would start by simply writing a program that:

accepts a string
Breaks the string into arguements or tokens using strtok
Store each individual arguement/token in an argument array
Print out the array so demonstrate that the command was successfully tokenised

That way you will see that the command has actually been broken up and stored. If you can get this going then your "minishell" will be on a good path.
 
Old 11-03-2006, 01:51 AM   #28
studentlb
Member
 
Registered: Oct 2006
Posts: 53

Rep: Reputation: 15
thanks a lot , i ll try to do this,hope i ll succeed.

Last edited by studentlb; 11-07-2006 at 02:22 PM.
 
Old 11-03-2006, 02:44 PM   #29
studentlb
Member
 
Registered: Oct 2006
Posts: 53

Rep: Reputation: 15
"accepts a string
Breaks the string into arguements or tokens using strtok
Store each individual arguement/token in an argument array
Print out the array so demonstrate that the command was successfully tokenised"

I succeeded with this
but actually now i m stucked in the redirection part :'(

Last edited by studentlb; 11-07-2006 at 02:21 PM.
 
Old 11-06-2006, 03:37 AM   #30
studentlb
Member
 
Registered: Oct 2006
Posts: 53

Rep: Reputation: 15
Please can u help me in the redirection part ?
thanks in advance
 
  


Closed Thread


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
Unix Shell Programming If Statement ']['HeBroken Programming 2 12-06-2004 03:21 PM
[c] unix systems programming in MS VS C++? saiz66 Programming 2 10-07-2004 08:16 AM
c programming in unix dilberim82 Programming 7 04-21-2004 04:32 PM
UNIX (Linux, BSD, etc) Programming :: UNIX kuphryn Programming 8 04-04-2004 11:50 PM
is there actually a market for Unix programming? ShawnD Programming 37 05-16-2003 04:16 PM

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

All times are GMT -5. The time now is 03:50 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
Open Source Consulting | Domain Registration