[nflug] Linux & Korn Shell Question

Michael James jamesm at thundertux.org
Tue Sep 12 10:14:30 EDT 2006

I'm transferring a script from an IBM AIX box to a Red Hat Enterprise 
Linux server.  One of the first lines in the script determines the 
logged in user and terminal the script is running under.  The syntax is:

who am i | awk '{ printf "%s %s\n", $1, $2; } ' | read user terminal

The first part give the standard output for the "who am i" command, the 
first field being the user and the second the terminal.  The "awk" 
command prints just the user and terminal with the idea that the output 
will be piped into the read command, giving me shell variables for the 
user and the terminal.  This line works fine under AIX and the Korn 
shell.  On Linux, each piece works fine at the CLI, but the entire line 
doesn't give me any values for the user and terminal variables.  I 
believe the issue is within the pipe.  Is there some parameter, switch 
or something that needs to be different under LInux?  The begining of 
the script is forcing the shell to the korn shell (/bin/ksh) and I've 
verified that.  Any help would be appreciated.

Michael R. James
jamesm at thundertux.org

nflug mailing list
nflug at nflug.org

More information about the nflug mailing list