Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Behaviour of gawk in AIX 4.3.3

Status
Not open for further replies.

Cuthie

Technical User
Sep 17, 2001
8
0
0
GB
Can anyone help me with an issue I have with gawk on AIX4.3.3?

The following worked with gawk on Tru64 unix but doesnt on AIX:-

[WAVESDEV:root]/usr/local/bin/waves> vi waves_create_staff
"waves_create_staff" 35 lines, 861 characters
gawk -F, -v username=$1 -v fullname="$2" -v password=$3 -v gname=$4 chopn=$5 '
$0 == "" { print $0 ; next }
{
split($1, a, "+")
if ( a[2] == gname )
printf "%s+%s", a[1], chopn
else
printf "%s+%s", a[1], username

if ( NF == 1 ) {
printf "\n"
next
}

if ( $2 == "DESCRIPTION" && a[2] != gname ) {
printf ",DESCRIPTION,%s\n", fullname
next
}

if ( $2 == "PASSWORD" && a[2] != gname ) {
printf ",PASSWORD,%s\n", password
next
}

if ( $2 == "MYGROUP" && a[2] != gname ) {
printf ",MYGROUP,%s\n", chopn
next
}

for( i=2; i <= NF; i++ ) {
printf &quot;,%s&quot;, $i
}
printf &quot;\n&quot;
}'


commmand is

cat file | above procedure passing variables.

get following error::-

gawk: cmd. line:2: fatal: cannot open file `
$0 == &quot;&quot; { print $0 ; next }
{
split($1, a, &quot;+&quot;)
if ( a[2] == gname )
printf &quot;%s+%s&quot;, a[1], chopn
else
printf &quot;%s+%s&quot;, a[1], username

if ( NF == 1 ) {
printf &quot;\n&quot;
next
}

if ( $2 == &quot;DESCRIPTION&quot; && a[2] != gname ) {
printf &quot;,DESCRIPTION,%s\n&quot;, fullname
next
}

if ( $2 == &quot;PASSWORD&quot; && a[2] != gname ) {
printf &quot;,PASSWORD,%s\n&quot;, password
next
}

if ( $2 == &quot;MYGROUP&quot; && a[2] != gname ) {
printf &quot;,MYGROUP,%s\n&quot;, chopn
next
}

for( i=2; i <= NF; i++ ) {
printf &quot;,%s&quot;, $i
}
printf &quot;\n&quot;
}' for reading (File name too long)
 
Was native awk unsatisfactory?

ad backslashes before ' or `
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top