i need a shell script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thisissin
    New Member
    • Jun 2007
    • 3

    i need a shell script

    i need to make a script that queries relevant system information from the /proc file system, the uname command, the output of dmesg, and possibly other sources on the system. the script should collect this information in variables, format it, then store it in a text file.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by thisissin
    i need to make a script that queries relevant system information from the /proc file system, the uname command, the output of dmesg, and possibly other sources on the system. the script should collect this information in variables, format it, then store it in a text file.
    Ok, so what do you have so far? Have you decided what shell you are using? Are you familiar with the different ways of getting that information?

    Comment

    • thisissin
      New Member
      • Jun 2007
      • 3

      #3
      #!/bin/bash
      #
      #
      #


      name=$(uname -s)
      version=$(uname -v)
      hardware=$(unam e -m)
      release=$(uname -r)
      mem=$(free -omt)
      disk=$(df -lh)
      hname=$(uname -n)
      cpu=$(cat /proc/cpuinfo | grep 'cpu MHz' | sed 's/cpu MHz//')
      cpumodel=$(cat /proc/cpuinfo | grep 'model name' | sed 's/model name//')
      who=$(whoami)
      lwho=$(logname)
      uptime=$(uptime |sed 's/,.*$//')
      #
      #
      echo "informatio n about your PC"
      echo "OS Type : $name"
      echo "Hostname : $hname"
      echo "Currently logged in as : $who"
      echo "CPU Model $cpumodel"
      echo "CPU Speed $cpu MHz"
      echo "Kernel Version : $version"
      echo "Kernel Release : $release"
      echo "System Uptime :$uptime"
      echo
      echo "Hard Disk"
      echo "$disk"
      echo
      echo "System Memory info"
      echo "$mem"
      echo
      echo "/proc file system info"
      procinfo=$(/usr/bin/procinfo)
      echo "$procinfo"
      echo
      dmesg > /tmp/dmesg.out
      cat /tmp/dmesg.out

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Looks like you're doing pretty well on this, did you have a question?

        Comment

        • thisissin
          New Member
          • Jun 2007
          • 3

          #5
          well at first when i read that scenario i was mindblow on where to start. but then looked at a couple sample scripts and went to town... all i need to do now is export all that information into a txt file.

          Comment

          • sicarie
            Recognized Expert Specialist
            • Nov 2006
            • 4677

            #6
            Originally posted by thisissin
            well at first when i read that scenario i was mindblow on where to start. but then looked at a couple sample scripts and went to town... all i need to do now is export all that information into a txt file.
            Oh cool, ok. Check this out. Looks like you can use the standard redirects in the script just as you would on the command line.

            Comment

            Working...