By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,789 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,789 IT Pros & Developers. It's quick & easy.

about output redirection

P: 4
hello!
I am currently writing my own script and need help on output redirection.as u know 'ls -al > myfile' would write the files in the current directory into the file called myfile.i know about opening a file and writing with fputc but have no idea about how to prevent the command from writing the output to terminal and get the output data to write to file..i hope i could tell my problem and someone could have an idea.
Nov 11 '07 #1
Share this Question
Share on Google+
5 Replies

numberwhun
Expert Mod 2.5K+
P: 3,503
hello!
I am currently writing my own script and need help on output redirection.as u know 'ls -al > myfile' would write the files in the current directory into the file called myfile.i know about opening a file and writing with fputc but have no idea about how to prevent the command from writing the output to terminal and get the output data to write to file..i hope i could tell my problem and someone could have an idea.
First, I have deleted your duplicate post. Please do not double post your questions.

Second, I am not sure that I understand. Are you saying that you want the default output for your Terminal to be a file instead of the screen? If that is the case, how will you know what you are doing? If that is NOT what you want, then you will really have to better explain your question as it is rather confusing.

Regards,

Jeff
Nov 11 '07 #2

P: 4
sorry about the duplicate post i tried to delete it but couldnt figure out how to do that.
i am trying to build a shell for my hw so if the user enters such a command "ls -al > myfile.txt" my shell should write the "ls -al" output into the myfile.txt instead writing to shell page..(just the same what bash shell does)
Nov 11 '07 #3

P: 4
prevent the command from writing the output to terminal .
i am talking about the output of "ls -al "here..not all of the outputs we get from the shell
Nov 11 '07 #4

pbmods
Expert 5K+
P: 5,821
Heya, zehrhand.

`ls -al > myfile.txt` doesn't do what you're expecting it to do?
Nov 11 '07 #5

P: 4
yea but i want to write a function which does that job.i dont want to use built-in functions..if my shell uses system functions for all jobs,then whats the point of writing a shell?
Nov 12 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.