| | |
Handling I/O redirections in my shell.
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2007
Posts: 17
Reputation:
Solved Threads: 0
Hi all.
This is my first post here, and i need urgent help with a programming assignment.
I am working on an assignment which requires me to build a simple shell. My shell must handle simple commands with arguements and ones with piping and I/O redirection.
The problem is i have no idea how to implement this redirection. The shell does alot of other things. I'm only stuck at this!
To further explain, my program reads the user's input such as: "ls -1 > text.txt" and does what a normal shell does. The problem is redirecting one's output as an input and the reverse. I have to execute two of the commands by forking two children and execve-ing. Then i need to do the redirection thing.
I have no idea were to start. I suppose it has to do with piping? I'm not sure.
Thanks alot for your help!
This is my first post here, and i need urgent help with a programming assignment.
I am working on an assignment which requires me to build a simple shell. My shell must handle simple commands with arguements and ones with piping and I/O redirection.
The problem is i have no idea how to implement this redirection. The shell does alot of other things. I'm only stuck at this!
To further explain, my program reads the user's input such as: "ls -1 > text.txt" and does what a normal shell does. The problem is redirecting one's output as an input and the reverse. I have to execute two of the commands by forking two children and execve-ing. Then i need to do the redirection thing.
I have no idea were to start. I suppose it has to do with piping? I'm not sure.
Thanks alot for your help!
I think you could use freopen to do it somehow... I'm not sure that it'll work, but hopefully it'll at least be a starting point.
•
•
•
•
Originally Posted by man freopen
The freopen() function opens the file whose name is the string pointed to by path and associates the stream
pointed to by stream with it. The original stream (if it exists) is closed. The mode argument is used just as
in the fopen() function. The primary use of the freopen() function is to change the file associated with a
standard text stream (stderr, stdin, or stdout).
![]() |
Similar Threads
- Good books on Shell Programming/Perl (Perl)
- Shell Programming (Shell Scripting)
- "Forbidden / You don't have permission to access / on this server." error (Linux Servers and Apache)
- Building a Shell. I'm in Hell (C++)
- another newbie with alot of redhat and apache server Q'S (Linux Servers and Apache)
- Shell HELP! (Getting Started and Choosing a Distro)
Other Threads in the C Forum
- Previous Thread: command line arguments help
- Next Thread: Server/Client timeout error
| Thread Tools | Search this Thread |
adobe ansi api array arrays bash binarysearch centimeter char character convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer license linked linkedlist linux linuxsegmentationfault list logical_drives match matrix meter microsoft motherboard multi mysql oddnumber odf open opendocumentformat openwebfoundation pattern pause pdf pointer pointers posix power problem program programming pyramidusingturboccodes read recursion recv recvblocked repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string strings structures suggestions system test testautomation unix urboc user voidmain() win32api windows.h






