People have asked what we'd like out of meetings.

I've been fighting my way through some shell scripting.

It's not until I actually start, to write that, I discover a bunch of stuff I hadn't heard mentioned.

eg.

Why would you code a line like this?

$IPTABLES_BIN -L traffic_in -vnx | $AWK_BIN '{if (int($1)!=0) print "INSERT INTO oncs.tblUsage (IPAddress, DataUsage, Direction) VALUES (\""$8"\","$2",\"I\");"}' > $ONCS_PATH/InData.sql

Why would you use $AWK_BIN rather than just typing awk ?

Answer: When you run the script from a cron session no (or limited) path is set (depending on factors), or you might use a different command for a different distro or you might want to use different versions of the binary, etc.

I've noticed coding a bit like this in scripts before but not understood why its done.

In most MS languages I've used you can't substitute commands with variables the way you clearly can in Linux shell scripting.

Ie.  I would read the example above as...

StringVariable1 -L traffic_in -vnx | StringVariable2 '{if (int($1)!=0) print "INSERT INTO oncs.tblUsage (IPAddress, DataUsage, Direction) VALUES (\""$8"\","$2",\"I\");"}' > StringVariable3/InData.sql

It's quite different to what I was used to in MS VB,VBA,ASP,FoxPro and others.

I must say that it's extreamly powerful.


Anyway, this was just a quick heads up for others who are playing about with a bit of shell scripting or having trouble understanding what they're reading.

HTH's someone

Cheers Don

--
Don Gould
www.thinkdesignprint.co.nz - www.tcn.bowenvale.co.nz - www.bowenvale.co.nz - www.hearingbooks.co.nz - www.buxtonsquare.co.nz - skype:ThinkDesignPrint?add - Good ideas: www.solarking.co.nz

Reply via email to