Hi AwkRookie,
Ha! I'm such a dope. I just repeated the mistake I was telling you about.
My message SHOULD have read:
I think your code sample isn't displaying quite right. This is because '[i]' in the code that got interpreted as a TGML instruction instead of as an array subscript.
You...
Hi AwkRookie,
I think your code sample isn't displaying quite right. This is because '[i]' in the code that got interpreted as a TGML instruction instead of as an array subscript.
You might want to unclick the 'Process TGML' checkbox just below the Reply editor.
When you resend your code, you...
Hi piggy213,
The top line (#!/usr/bin/awk -f) is called the 'shebang line'.
The shebang line tells the Unix/Linux environment that this is specifically an awk script (as opposed to a Bourne-shell or c-shell script, for example). You need a different shebang line for awk, c-shell...
Hi,
Earlier I mentioned that you could use the Unix/Linux date command with special formatting capabilities. I thought I would take the opportunity to show how they can be used.
First I will show an excerpt from the man page for date (on an AIX box) with an example, then I will show a small...
Hi piggy213,
Well, I think marsd has pretty much given you everything you need, except I think you are saying that the '/error/' line might not necessarily show up on the line immediately following the date.
With that in mind, I wrote the following, but it's totally based on marsd's stuff...
Hi piggy213,
If strftime() is not available, I think you could use getline to get the system date (using the *nix 'date' command). You might want to use it's format string features, so if you are not familiar with them, you would have to check the man pages (man date).
(Sorry, I would get it...
Hi sinebubble,
I wonder if you have thought of trying it using getline, instead of system? Eg:
#!/bin/sh
df -k | grep -v cdrom | grep -v : | sed 1d | sed 's#%##' | awk '
{
if ( $5 > 10 )
{
print "ALERT: "$6 " is " $5 "% full on "
}
else...
Hi sinebubble,
Do we know for sure that it is going into the 'else if' block so that it is reaching the system() call? ie:
else if ( $5 > '$MAIL_NUMBER' )
{
print "WARNING: "$6 " is " $5 "% full on ";
system("du -adko "$6" |...
Hi sinebubble,
By the way, I am suspicious of the reference to $PAGE_NUMBER and $MAIL_NUMBER.
It looks like these are supposed to be shell variables. I can't test it right now, but I'm pretty sure you can't reference them directly from within awk. (Excuse me in advance if you know otherwise)...
Hi sinebubble,
I unravelled your code and it looked like this:
df -k | grep -v cdrom | grep -v : | sed 1d | sed 's#%##' | awk '{
if ( $5 > '$PAGE_NUMBER' )
{
print "ALERT: "$6 " is " $5 "% full on "
}
else if ( $5 > '$MAIL_NUMBER' )
{
print...
Hi dvanan,
In your previous message, you said:
>Tried some debug but I'm quite new to the "for ( a in b)" syntax so was st(r)uck !
It's quite straightforward. You can print each subscript in the array using the following syntax:
for ( variable in array )
{
print variable;
}...
Hi dvanan,
I forgot to turn off TGML and it treated a '[i]' as a command to italicize.
So here is the new version once again:
#!/usr/bin/awk -f
BEGIN{
a[0]=32
a[1]=10
a[2]=32
a[3]=14
a[4]=16
a[5]=10
a[6]=32
for ( i in a ) { b[a[i]]+=1; }
for ( count=1; count<=3...
Hi dvanan,
Here's the new version:
#!/usr/bin/awk -f
BEGIN{
a[0]=32
a[1]=10
a[2]=32
a[3]=14
a[4]=16
a[5]=10
a[6]=32
for ( i in a ) { b[a[i]]+=1; }
for ( count=1; count<=3; count++)
{
highest=0;
for ( j in b )
{
if (highest < b[j]){ highest=b[j]...
Hi dvanan,
Try this:
#!/usr/bin/awk -f
BEGIN{
a[0]=32
a[1]=10
a[2]=32
a[3]=14
a[4]=16
a[5]=10
a[6]=32
for ( i in a )
{
b[a[i]]+=1;
}
for ( count=1; count<=3; count++)
{
highest=0;
for ( j in b )
{
if (highest < j){ highest=j }
}
print...
Hi ejaj,
I realize this does not answer the question as to why the dos copy command is failing when using the backtick technique, but if you are only interested in copying files, perhaps you might try File::Copy. If you are using ActiveState Perl, it should be included.
use File::Copy...
Hmmm,
I am puzzled.
I ran the identical code on my box and, as expected, it works just fine. Therefore it's not syntax.
My conclusion is that getline exists on your system, but it seems to be too primitive to support the functionality that we take for granted. Apparently, you just have an...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.