HELP WITH NAWK

mark hilliard mark at gizzmo.UUCP
Sun Dec 3 09:00:26 AEST 1989


Help, I am having a problem with a if statement with a nested system test 
statement working the reverse of what I think it should.  The entire nawk 
program is included for evaluation, but the lines in question are marked.

Thanks for the help!

nawk '
BEGIN { FS = ":" }

# Check for user directories and create them if necessary
$3 > 99	{ 

# for some reason this nested system if works in reverse order

-------------------------HERE IT IS!! ----------------------------------------

if ( system("test -d "$6)) {
  printf("\r\n--- %s does not exist, creating it and moving files --- \r\n",$6) 
  system("mkdir "$6) 
  }
else 
  printf("--- %s exists, moving files now ---\r\n",$6) 

}
--------------------------ABOVE------------------------------------------------
# Move files to proper user directories and set permissions and ownership
$3 > 99	{ 

# Copy file to user home account path

	  system("cp /etc/stdprofile " $6"/.profile")
	  system("cp /etc/stdcshrc " $6"/.cshrc")
	  system("cp /etc/stdkshrc " $6"/.kshrc")
	  system("cp /tmp/faxcover " $6"/.faxcover")
	  system("cp /usr/lib/mailx/mailx.rc " $6"/.mailrc")


# Change permissions

	  system("chmod 755 " $6"/.kshrc")
	  system("chmod 755 " $6"/.cshrc")
	  system("chmod 755 " $6"/.profile")
	  system("chmod 755 " $6"/.mailrc")
	  system("chmod 755 " $6"/.fax*")

# Change ownership to proper owner

	  system("chown " $3" "$6"/.kshrc")
	  system("chown " $3" "$6"/.cshrc")
	  system("chown " $3" "$6"/.profile")
	  system("chown " $3" "$6"/.mailrc")
	  system("chown " $3" "$6"/.fax*")

	  system("ls -ol " $6"/.profile")
	  system("ls -ol " $6"/.cshrc")
	  system("ls -ol " $6"/.kshrc")
	  system("ls -ol " $6"/.mailrc")
	  system("ls -ol " $6"/.fax*")

          printf(".rc files copied for user %s in %s\r\n",$1,$6) 
}

' /etc/passwd

Mark Hilliard
N2HHR
rutgers!rochester!kodak!gizzmo!mark



More information about the Comp.unix.i386 mailing list