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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix script question

Status
Not open for further replies.

rrrirvine

MIS
Oct 19, 2001
7
US
Hi..

I have script running on each my systems to grab the user logging activities and send it to securty control system which creates the output file on system. So when security people can view the the output file for desired system.
This output file will be stored on security system under specific directory.

Now I would like to enhance this for security people so they can select desired system to view the output.
So far I craeted manually data file which I have to update and system added or deleted.
Is there any way I can display the listing of all directory so it will display on screen and user can select the system.
help is really appreciated.

Thanks,
 
You could do something along these lines. Assuming you've got nicely named files, you could do

Code:
#!/bin/sh
ls -1 > /tmp/filelist.txt
(that is ls -number one)
Code:
grep -in '^' /tmp/filelist.txt
echo Enter Choice
read CHOICE
cat `tail +CHOICE /tmp/filelist.txt | head -1`

Sort of a cheesy way of creating a dynamic menu of the files in the current directory and just
Code:
cat
ing them. --
Andy
 
Thank You...I got so far close. the last command gives the error.

cat `tail +CHOICE /tmp/filelist.txt | head -1`
Also in my case, I have about 500+ files and thoses files to display on screen is horrible so is there any way we can fill the screen and for next screen wait for input like that.

Regards,
 
You could pipe the grep output to pg or more
eg
grep -in '^' /tmp/filelist.txt | pg
or
grep -in '^' /tmp/filelist.txt | more

Hit enter or space to scroll down - This could spoil the input of $choice, but then perhaps you could check that $choice has a length ?

HTH

Dickie Bird (:)-)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top