PDA

View Full Version : Printing to a file


dec
06-01-2004, 11:42 PM
Hi

How to print the results of a script like logwatch to a file in linux?

Thanks

Dec

vandal
06-02-2004, 12:23 AM
hello

pico -w /etc/log.d/logwatch.conf

find the line


# if set, the results will be saved in <filename> instead of mailed
# or displayed.
#Save = /tmp/logwatch


remove the # in front of Save and put in your path

such as

Save = /tmp/logwatch

all done, but you will not get an e-mail anymore.

once logwatch is run from crond later that day you should be able to

pico - w /tmp/logwatch

and see your results.

dec
06-02-2004, 12:29 AM
Thanks Vandal..! ;)

I actually figured it out o couple minutes ago :D

But in general.. What would be the command to print results of a batch to a file?

Regards

Dec

vandal
06-02-2004, 12:31 AM
what do you mean batch?

dec
06-02-2004, 12:32 AM
bash.. :p

vandal
06-02-2004, 12:39 AM
well i'm not totally sure what you mean :)

but this might be helpful

command > /tmp/output.txt

or to append (add to the end)

command >> /tmp/output.txt

for example



service httpd restart > /tmp/output.txt

then

cat /tmp/output.txt

if this isn't what you mean let me know :)

dec
06-02-2004, 12:43 AM
Originally posted by vandal
well i'm not totally sure what you mean :)

but this might be helpful

command > /tmp/output.txt

or to append (add to the end)

command >> /tmp/output.txt

for example



service httpd restart > /tmp/output.txt

then

cat /tmp/output.txt

if this isn't what you mean let me know :)


Sorry for the confusion..

So basically you are saying that with this:

command > /tmp/output.txt

I will get the results of the command in the file output.txt ?

Dec

vandal
06-02-2004, 12:45 AM
you bet,

then use cat to print the newly created file to screen and you will see the results of that command.

cat /tmp/output.txt

dec
06-02-2004, 12:49 AM
WOW man!

That's what i was looking for! :D

Thanks a lot

Dec

vandal
06-02-2004, 12:51 AM
you are very much welcome :)