[TriLUG] Basic bash shell scripting question

Ryan Leathers ryan.leathers at globalknowledge.com
Thu May 29 09:40:51 EDT 2003


Hi gang. I am writing an application in Java, part of which needs to add
the user name of a user logging onto a Linux host to a plain text list
of user names.  (don't worry - this is not required or intended to be
secure). The user will launch this application from their login script.
It occurred to me that the simplest way to do this was to use JNI to
drop to a bash shell and then mess with the file as needed in Java later
on.  I suppose I could just launch the script independently of the Java
app and get the same thing... but thats not really the point.

I have rarely done shell scripting over the years and am looking for
some advice.  The lines below will do what I want, but how can I make
this more elegant?  Can I accomplish this without creating deleting and
renaming as seen below?   

whoami > name
cat checked.txt name > checked.new
rm checked.txt
rm name
mv checked.new checked.txt

Thanks,
Ryan




More information about the TriLUG mailing list