Scripting for Inventory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting for Inventory
# 1  
Old 07-17-2011
Scripting for Inventory

Hi,

I am getting all the scripts in my unix box through ls and pasting them in a xls for the Inventory Purpose.

Right now I am doing it manually I am going manually in each directory and doing a ls > temp.txt and pasting this out put in xls manually.

Is there any way to automate this ..if I run some script in my root directory it should get the folder path , folder name and the script in that folder.

As I said I am doing it manually I don't know how to get started on this..pls tell me some logic for doing this.

Regards,
Deepti
# 2  
Old 07-17-2011
ls can list recursively
Code:
ls -1R

But if you need csv format for Excel then example:
Code:
#!/usr/bin/ksh
# or bash or dash or ...
# ls2

# directories
dirs=$(find . -type d | sed "s/^.\///")

nowdir=$PWD
# filelist / dir
echo "$dirs" | while read dir
do
        cd "$nowdir/$dir"
        files=$(find . -type f | sed "s/^.\///")
        echo "$files" | while read file
        do
                echo "$dir;$file"
        done
done

Then
Code:
chmod a+rx ls2
./ls2 > mylist.csv

---------- Post updated at 07:58 PM ---------- Previous update was at 07:06 PM ----------

Or you can make XML format which is also usable into Excel.
Code:
# directories
xmlout()
{
cat <<EOF
<File>
  <Dir>$1</Dir>
  <Filename>$2</Filename>
</File>
EOF
}


#MAIN
dirs=$(find . -type d | sed "s/^.\///")

# XML header
cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata">
EOF

nowdir=$PWD
# filelist / dir
echo "$dirs" | while read dir
do
        cd "$nowdir/$dir"
        files=$(find . -type f | sed "s/^.\///")
        echo "$files" | while read file
        do
                xmlout "$dir" "$file"
        done
done
echo "</dataroot>"

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

UNIX/Linux inventory - Open Source

Hello guys, I need an open source tool that can list all the softwares installed in my unix/linux servers, the tool should list all the softwares installed and the current version, grouped by the hostname, anybody know any solution for this specific problem? Thanks guys, have a good day! (7 Replies)
Discussion started by: denisloide
7 Replies

2. UNIX for Advanced & Expert Users

Server inventory software

Hi, do you know any good server inventory open source products? I want information like, server hostnames, ram, cpu, os, filesystems, volume groups, disks, adapters, installed software versions, firmware levels and so on os: aix, solaris, linux, hpux data should be kept in a database, web... (7 Replies)
Discussion started by: funksen
7 Replies

3. Solaris

Inventory details - Solaris

i need to extract following information through command line on solaris machine : 1.manufacturer name (hardware as well as OS) 2.Model number 3.Serial number - Serial Number of the device or the Physical device serial number for Virtual Servers 4.whether the server is physical or virtual -... (3 Replies)
Discussion started by: omkar.jadhav
3 Replies

4. UNIX for Dummies Questions & Answers

Folders and Files Inventory

Hi , We are migrating our scripts from one unix server to another unix server in aix. Is there any way we can export the permissions, owner, group of the folders and files inside the folders. If I am copying xyz folder from old server, I need to generate a report with permissions ,owner and... (5 Replies)
Discussion started by: shruthidwh
5 Replies

5. Shell Programming and Scripting

Help on editing inventory

Hi guys, im currently doing a library database program, and i need help for the following commands my library.txt is Google:Harry:45.00:50:100 This is my code echo "Please enter Title" read BookTitle echo "Please enter Author" read Author echo "Price" read Price ... (2 Replies)
Discussion started by: ichar
2 Replies

6. Shell Programming and Scripting

File Inventory Scan

Is there such a script out there that will Analyze a folder and subfolders, getting file type utilization and file aging. A CSV file will be created with file information File,Size,Date Created,Last Modified,Last Accessed,Extension,File Type,Owner A Summary report text file will also be created... (4 Replies)
Discussion started by: seacros
4 Replies

7. UNIX for Advanced & Expert Users

Collecting software inventory

how to obtain/ collect a list of all the applications installed in the system.. is there a configuration file(like the one which exists for hardware ) which holds all this information?? if no is there any command/shell script or utility that we can use for the same ?? I am using Red hat linux... (2 Replies)
Discussion started by: superghost
2 Replies

8. UNIX for Dummies Questions & Answers

Software Inventory

How can I find out what software is installed on the machine, other than ls? Is there a registry program like in Windows? The os is Sun 2.5. Thanks (1 Reply)
Discussion started by: ViperD
1 Replies
Login or Register to Ask a Question