Help making LOGFILE

Help making LOGFILE

Post by JGM_van_Ra » Sat, 15 Mar 1997 04:00:00



Hello

I 've a problem with making a logfile under a csh shell script.
The data for entering in the logfile I use in the script the
following
command :

  echo "$DATA1          $DATA2" >> logfie.log
              |_2 Tabs_|

I use between DATA1 en DATA2 two tabs.
The output from logfile.log after 3 times running the script is

        DATA1           DATA2
        -----------------------------------
line1   xxxxxx          xxxxxxxxxxxx
line2   xxxxxxxxxx              xxxxxxxxx
line3   xxxxxxxxxx              xxxxxxxxx

This is coming throught that teh DATA is different.
How can I make it that the colunms in the logfile.log are
straight without
edit the file?
Is this possible to do it in the srciptfile?

Any help will be greatly apprciated.

 
 
 

Help making LOGFILE

Post by Per Kistle » Sat, 15 Mar 1997 04:00:00


Hi

#!/usr/bin/csh
set data1="first entry"
set data2="second entry"
nawk -v data1="$data1" -v data2="$data2" 'BEGIN{           \
      printf("%-20s%-20s\n",data1,data2) >> "logfile.log"  \

Quote:}' /dev/null

The idea is somehow to utilize the printf command, here it
happens with nawk. Then the columnwidth is fixed.

But it seems strange to start the awk command individually
for every line of output, so one would have to improve it
somehow...

Bye, Per.
--
Per Kistler, Zuerich, Switzerland. (Unix/Perl/C++)
----------------------------------------------------------------------

 
 
 

Help making LOGFILE

Post by Bill Marc » Sat, 15 Mar 1997 04:00:00



>Hello

>I 've a problem with making a logfile under a csh shell script.
>The data for entering in the logfile I use in the script the
>following
>command :

>  echo "$DATA1          $DATA2" >> logfie.log
>              |_2 Tabs_|

>I use between DATA1 en DATA2 two tabs.
>The output from logfile.log after 3 times running the script is

>        DATA1           DATA2
>        -----------------------------------
>line1   xxxxxx          xxxxxxxxxxxx
>line2   xxxxxxxxxx              xxxxxxxxx
>line3   xxxxxxxxxx              xxxxxxxxx

>This is coming throught that teh DATA is different.
>How can I make it that the colunms in the logfile.log are
>straight without
>edit the file?
>Is this possible to do it in the srciptfile?

>Any help will be greatly apprciated.


If you don't mind having spaces instead of tabs between fields, you could
use printf.

--
Bill Marcum    bmarcum at iglou dot com
"...and eleven long haired friends of Jesus in a chartreuse microbus..."

 
 
 

Help making LOGFILE

Post by Brian S Hil » Sat, 15 Mar 1997 04:00:00


: Hello
: I 've a problem with making a logfile under a csh shell script.
: The data for entering in the logfile I use in the script the
: following command :
:   echo "$DATA1          $DATA2" >> logfie.log
:               |_2 Tabs_|
: --
: I use between DATA1 en DATA2 two tabs.
: The output from logfile.log after 3 times running the script is
:         DATA1           DATA2
:         -----------------------------------
: line1   xxxxxx          xxxxxxxxxxxx
: line2   xxxxxxxxxx              xxxxxxxxx
: line3   xxxxxxxxxx              xxxxxxxxx
: --
: This is coming throught that teh DATA is different.
: How can I make it that the colunms in the logfile.log are
: straight without
: edit the file?
: Is this possible to do it in the srciptfile?
: Any help will be greatly apprciated.

You _do_ realise that the tabulation is appropriately justifying to the
column position where the length of DATA1 on line1 leaves it, don't you?

Using csh is problematic, at best. Especially concerning I/O. In ksh
this would quite simple. The solution is to investigate whether
your system has the "/bin/printf" command, or failing that, use awk:

echo "$DATA1    $DATA2" >> /tmp/log
#           ^^^^ ONE tab now!
...
awk -F'<TAB>' '{ printf "%14s %14s\n", $1, $2 }' /tmp/log >logfile.log

-Brian
--
   ,---.     ,---.     ,---.     ,---.     ,---.     ,---.     ,---.  
  /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \  

__,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.__

 
 
 

Help making LOGFILE

Post by era eriksso » Mon, 17 Mar 1997 04:00:00


On Fri, 14 Mar 1997 18:55:05 +0100,

 > The idea is somehow to utilize the printf command, here it
 > happens with nawk. Then the columnwidth is fixed.

For completeness' sake, let's not forget expand(1)

 $ echo -e "moo\t\tmoo" | expand -12,14
 moo           moo
 \...... ....../
        v
14 character positions

/* era */

--
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

 
 
 

1. networking logfiles/making sshd more secure

Redhat 7.1

Last night some wanker broke into my machine, starting up a whole lot
of ftp processes and chewing up my modem's limited bandwidth....and
then after I killed off their FTP process twice they appear (from
looking at /var/log/secure) to have used ssh to execute some command
on my machine that has messed up some of my utilities - I can no
longer execute some of the files in /bin (like ps and top) and some of
the files in /sbin (like ifconfig and ifup) - I get the error "bash:
[filename]: No such file or directory" even though I can see the files
still exist and the directories is in my $PATH variable (attempting to
execute them from the directory doesn't work either) - although
utilities like ls seem to still work....

anyhow, I was curious,

A) if anyone knows how to beef up sshd's security (none of the
passwords for accounts on my machine are simple word combinations or
anything that should have given in to a password cracker), and

B) where on my system could I expect to find more information about
exactly what happened? (/var/log/secure has a little info, listed
below in case someone can help me out and tell me how to fix this hole
in my machine's security, and there doesn't seem to be any other sshd
log files - I would like to find out what command was executed and how
to reverse it)....I think the sshd daemon is openSSHd 1.24r2 (there is
no option for the binary sshd to return tis version number but a
locate sshd on my system turns up that number....)

If anyone can help me out here I would much appreciate it....I would
like to turn SSHd back on ;->

-d

2. I'm Stuck!- Partitioning question

3. Making sense of Apache's mod_usertrack logfiles...?

4. Problems with RPM

5. How I check dead logfile. Please help

6. Printing API

7. Please help me with logfiles.

8. SGML and xman

9. Help! Supporting of millisecond time in logfile

10. Help with logfile messages!!!!!!!!!!

11. Customized Apache Logfile Help Needed

12. split-logfile Problems, PLEASE HELP!!!

13. logfile help