Help!

redirecting standard output

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions (archive 1) RSS
Next:  chroot + su + env?  
Author Message
Angel Tsankov
External


Since: May 04, 2006
Posts: 66



PostPosted: Thu May 04, 2006 8:47 pm    Post subject: redirecting standard output
Archived from groups: comp>os>linux>misc (more info?)


How can a shell script redirect its standard output to a file?
Back to top
ynotssor
External


Since: May 06, 2005
Posts: 618



PostPosted: Thu May 04, 2006 8:47 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Angel Tsankov" wrote in message


> How can a shell script redirect its standard output to a file?

Shouldn't you be doing your own homework? Such as reading the man page for
whatever shell you're using and searching for "redirect".
Back to top
Chirag Shukla
External


Since: May 12, 2006
Posts: 247



PostPosted: Thu May 04, 2006 8:47 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Standard output to a file
../your_script_name > your_file_name.log
will send the standard output to the log file (In Windows you do the
same thing too, provided you get a standard output). The ">" sign is
the standard output symbol. With each run of your script, the log file
will be overwritten

../your_script_name >> your_file_name.log
will append the standard output to your log file. That means, your log
file keeps on growing in size.

Learn from other user's comments. Try to read the manual. If you are a
new Linux user, I would ask you not to directly look into "man".
Rather, go to google and learn how to use "man", learn how to use "vi"
etc. From there on, you will get some confidence and will enjoy working
with Linux. In google if you search for "man bash", you will get manual
pages for BASH. Read about Redirection as suggested by other users.


Chirag Shukla
Back to top
Dan Espen
External


Since: Jan 16, 2006
Posts: 496



PostPosted: Thu May 04, 2006 8:47 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Angel Tsankov" writes:

>>>>> How can a shell script redirect its standard output to a file?
>>>> Shouldn't you be doing your own homework? Such as reading the man
>>>> page for
>>>> whatever shell you're using and searching for "redirect".
>>>
>>> How do I search in a man page?
>> It depends on your pager. With most of the ones I'm
>> acquainted with, you press '/' (without the quotation
>> marks), which brings up a prompt at the bottom of the
>> terminal window; then you enter the text to search and press
>> the <Enter> key. You may find the following commands
>> worthwhile as study:
>> man man
>> man more
>> man less
>> man most
>
> Why don't you just explain how a script can redirect its own standard output,
> instead of beating about the bush...

You are wasting your time taking computer science classes.
I suggest something to prepare you for management.
Back to top
Angel Tsankov
External


Since: May 04, 2006
Posts: 66



PostPosted: Thu May 04, 2006 9:23 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>> How can a shell script redirect its standard output to a file?
>
> Shouldn't you be doing your own homework? Such as reading the man page for
> whatever shell you're using and searching for "redirect".

How do I search in a man page?
Back to top
Robert M. Riches Jr.
External


Since: Apr 19, 2004
Posts: 1289



PostPosted: Thu May 04, 2006 9:23 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2006-05-04, Angel Tsankov wrote:
>>> How can a shell script redirect its standard output to a file?
>>
>> Shouldn't you be doing your own homework? Such as reading the man page for
>> whatever shell you're using and searching for "redirect".
>
> How do I search in a man page?

It depends on your pager. With most of the ones I'm
acquainted with, you press '/' (without the quotation
marks), which brings up a prompt at the bottom of the
terminal window; then you enter the text to search and press
the <Enter> key. You may find the following commands
worthwhile as study:

man man
man more
man less
man most

HTH

--
Robert Riches
spamtrap42.DeleteThis@verizon.net
(Yes, that is one of my email addresses.)
Back to top
Angel Tsankov
External


Since: May 04, 2006
Posts: 66



PostPosted: Thu May 04, 2006 10:23 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>>>> How can a shell script redirect its standard output to a file?
>>>
>>> Shouldn't you be doing your own homework? Such as reading the man page for
>>> whatever shell you're using and searching for "redirect".
>>
>> How do I search in a man page?
>
> It depends on your pager. With most of the ones I'm
> acquainted with, you press '/' (without the quotation
> marks), which brings up a prompt at the bottom of the
> terminal window; then you enter the text to search and press
> the <Enter> key. You may find the following commands
> worthwhile as study:
>
> man man
> man more
> man less
> man most

Why don't you just explain how a script can redirect its own standard output, instead of beating about the bush...
Back to top
ynotssor
External


Since: May 06, 2005
Posts: 618



PostPosted: Thu May 04, 2006 10:23 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Angel Tsankov" wrote in message


>> You may find the following commands worthwhile as study:
>>
>> man man
>> man more
>> man less
>> man most
>
> Why don't you just explain how a script can redirect its own standard
> output, instead of beating about the bush...

Bite the hand that feeds you.
Back to top
Robert M. Riches Jr.
External


Since: Apr 19, 2004
Posts: 1289



PostPosted: Thu May 04, 2006 10:23 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2006-05-04, Angel Tsankov wrote:
>>>>> How can a shell script redirect its standard output to a file?
>>>>
>>>> Shouldn't you be doing your own homework? Such as reading the man page for
>>>> whatever shell you're using and searching for "redirect".
>>>
>>> How do I search in a man page?
>>
>> It depends on your pager. With most of the ones I'm
>> acquainted with, you press '/' (without the quotation
>> marks), which brings up a prompt at the bottom of the
>> terminal window; then you enter the text to search and press
>> the <Enter> key. You may find the following commands
>> worthwhile as study:
>>
>> man man
>> man more
>> man less
>> man most
>
> Why don't you just explain how a script can redirect its own standard
> output, instead of beating about the bush...

Why don't you learn to press the <Enter> key to comply with
the netiquette rule to limit line length to about 72
characters? 1/2 Smile

You asked, "How do I search in a man page?" I attempted to
answer that question.

Your question about output redirection was earlier in the
thread. As is, that question is so nebulous it is not
feasible to attempt to answer.

--
Robert Riches
spamtrap42.DeleteThis@verizon.net
(Yes, that is one of my email addresses.)
Back to top
Robert Hull
External


Since: Oct 31, 2004
Posts: 1219



PostPosted: Fri May 05, 2006 9:49 am    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In comp.os.linux.misc, on Thu 04 May 2006 20:23, Angel Tsankov
wrote:

>>
>> man man
>> man more
>> man less
>> man most
>
> Why don't you just explain how a script can redirect its own standard
> output, instead of beating about the bush...

Possibly because you are paying him less than you are paying your tutor
who set you this homework.

Or possibly because teaching you to find the answer for yourself is
better than helping you to cheat on your homework.
--
Robert HULL

Archival or publication of this article on any part of thisishull.net
is without consent and is in direct breach of the Data Protection Act
Back to top
Unruh
External


Since: May 27, 2005
Posts: 2213



PostPosted: Fri May 05, 2006 2:54 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Chirag Shukla" writes:

>Standard output to a file
>./your_script_name > your_file_name.log
>will send the standard output to the log file (In Windows you do the
>same thing too, provided you get a standard output). The ">" sign is
>the standard output symbol. With each run of your script, the log file
>will be overwritten

I think he is asking how the shell script itself can redirect its own
output to a file. NOt hoow you can redirect its standard output to a file.
Back to top
Steve Wampler
External


Since: Dec 08, 2004
Posts: 58



PostPosted: Fri May 05, 2006 2:54 pm    Post subject: Re: redirecting standard output [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Chris F.A. Johnson wrote:
> On 2006-05-05, Unruh wrote:
>> "Chirag Shukla" writes:
>>
>>> Standard output to a file
>>> ./your_script_name > your_file_name.log
>>> will send the standard output to the log file (In Windows you do the
>>> same thing too, provided you get a standard output). The ">" sign is
>>> the standard output symbol. With each run of your script, the log file
>>> will be overwritten
>> I think he is asking how the shell script itself can redirect its own
>> output to a file. NOt hoow you can redirect its standard output to a file.
>
> There's a difference?

Sure. In the obvious case, the person running the script is doing
the redirection. In the desired case, the script itself is doing
the redirection without user intervention.

That being said, it's trivial to do by wrapping one shell script in
another as well as a number of other simple ways.


--
Steve Wampler -- swampler.RemoveThis@noao.edu
The gods that smiled on your birth are now laughing out loud.
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions (archive 1) All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum