-1

I want to writing a script in shell for solaris paltform regarding some below commands and their output should written in excel file or text file as a output.

  1. How many servers are deployed under global

    zone --- zoneadm list -cv 
    
  2. H/w architecture

    showrev -a  
    
  3. OS Related Information

    uname -a
    
  4. RAM and its Utilization

    echo "::memstat" | mdb -k
    
  5. Internal Disk

    echo | format
    
  6. Which service is running on which node

    hares -state |grep "ONLINE"
    
  • 2
    Sounds good, give it a try and let us know how it goes! – John Zwinck Jan 21 '15 at 06:11
  • The easy bit is running the 6 commands; you write them in a single file and make it executable and run it. Outputting the information to a text file is trivial — run the script with its output saved in a file: `/path/to/script > /tmp/some.file`. The hard bit is formatting the output for use in Excel. – Jonathan Leffler Jan 21 '15 at 06:13
  • do you want me to write all these commands in a text file and exceute it one by one – Mohit Bhardwaj Jan 21 '15 at 06:19
  • @JohnZwinck....fyn its working when i put it in a simple script as a executable file. – Mohit Bhardwaj Jan 21 '15 at 06:41
  • Now i am exceuting the above like this can you do me a favour please tell how would i more intresting and more visible to the user #!/bin/bash ##How many servers are deployed under global zoneadm list -cv ############################ ##H/w architecture showrev -s master-d ##OS Related Information uname -a ##RAM and its Utilization prtdiag ##Internal Disk echo | format ##Which service is running on which node /opt/VRTSvcs/bin/hares -state |grep "ONLINE" exit 0 – Mohit Bhardwaj Jan 21 '15 at 09:29
  • @JonathanLeffler....can please breif me for further help – Mohit Bhardwaj Jan 22 '15 at 06:05

1 Answers1

0

Solaris is a not something I am familar with. I think I have logged in once or twice in my life.

However, unix/linux I have some experience with.

You simple need to put your commands in a script file often ends with *sh (myscriptfile.sh). then you simply run the script.

That being said. You need to read up on output redirect (that is out you write the output to file).

And learn more about your 'shell'. I would further recommend using bash (I believe out-of-the-box solaris uses something different). Bash scripting is far more popular therefore you will find greater support.

terary
  • 940
  • 13
  • 30
  • 1
    FWIW: [Commandname extensions considered harmful](http://www.talisman.org/~erlkonig/documents/commandname-extensions-considered-harmful.shtml). – gniourf_gniourf Jan 22 '15 at 07:01