[nflug] Linux & Korn Shell Question

Richard Hubbard rhubby at yahoo.com
Tue Sep 12 11:21:50 EDT 2006


Add this to the top line of the script...

#!/bin/ksh

this is assuming 1) that you have the korn shell installed
2) it is in the bin directory

If you are using something that 'acts like' the korn shell (zsh?) then use that instead.  
(I think the actual korn shell is copyrighted, so gnu has an act alike.  however, I think that there is usually a symbolic link pointing to the 'act alike', similar to what is done with csh and tcsh (and, come to think of it, awk and gawk)

 
Richard Hubbard Technology Solutions Inc

----- Original Message ----
From: Michael James <jamesm at thundertux.org>
To: nflug at nflug.org
Sent: Tuesday, September 12, 2006 10:14:30 AM
Subject: [nflug] Linux & Korn Shell Question

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
http://www.nflug.org/mailman/listinfo/nflug




_______________________________________________
nflug mailing list
nflug at nflug.org
http://www.nflug.org/mailman/listinfo/nflug



More information about the nflug mailing list