LinuxQuestions.org
Review your favorite Linux distribution.
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-14-2014, 02:46 PM   #1
ramxo
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Rep: Reputation: Disabled
Red face C code for a mini shell


my Assignment is to
write a a program which takes input from user .
then modify the program enabling to check the contents of a directory now modify it to check if the input string is present in the \bin or \sbin directory
 
Old 09-14-2014, 02:50 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Great - what have you tried so far and what problems are you having? No one on this forum is going to do your homework for you, but we may be able to help if you give it an honest effort and run into trouble. One thing to note, the *nix path separator is a forward slash, not a backslash as in DOS, so it's not \bin and \sbin but rather /bin and /sbin.
 
Old 09-14-2014, 02:59 PM   #3
ramxo
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
i am completely new to linux C programming and i m searching how can i start , just found this forum and registered here . maybe someone will help me getting starts . and sorry for the slash as you guys can understand how it feels when you dont have a clue about the thing you will have to work with .
 
Old 09-14-2014, 03:49 PM   #4
jkirchner
Member
 
Registered: Apr 2007
Location: West Virginia
Distribution: LinuxMint 18
Posts: 738

Rep: Reputation: 179Reputation: 179
Have you read through the rules for the forums? This is one of the points:

Quote:
Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.
Read the rules here.

Like btmiller said, post what you have tried first and then we can help. Noone will write it for you.
 
Old 09-14-2014, 05:09 PM   #5
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 490Reputation: 490Reputation: 490Reputation: 490Reputation: 490
The getting user input is easy, you should already know how to do that, and you probably have more details on exactly what is required.

As for the directory listing, this is not part of the standard C library, so you will either have to:
1) Use the 'system()' function to execute the right command.
http://www.cplusplus.com/reference/cstdlib/system/
2) Use glib:
https://developer.gnome.org/glib/2.4...tml#g-dir-open
 
1 members found this post helpful.
Old 09-14-2014, 05:19 PM   #6
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Usually a "real" Unix shell like bash would use stat(2) or one of its variants to check and see if a file exists somewhere in its $PATH.

To the OP - if this is homework you must be taking a class. Did your lectures not cover what you need to know to complete the assignment? If not, maybe you should seek clarification from your professor...
 
1 members found this post helpful.
Old 09-14-2014, 07:03 PM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
Maybe glibc opendir(), readdir()..?
 
2 members found this post helpful.
  


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
win32,shell code,shell programming,shell scripting? mr.cracker Linux - Newbie 4 07-13-2013 12:20 AM
linux mini-c shell handling background processes micflunu Programming 2 12-05-2012 03:43 AM
linux mini-c shell handling background processes micflunu Programming 1 12-04-2012 04:36 PM
Need Watchdog timer code for MINI-ITX VIA CN700-8237 MBoard johnfkav Linux - Hardware 0 01-09-2010 02:16 AM
ASUS Eee mini laptop- how to get a (bash) shell running? vous Linux - Hardware 1 06-19-2008 05:06 AM


All times are GMT -5. The time now is 06:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration