Jump to content
Sign in to follow this  
Followers 0

Application: Linux System Script

71 posts in this topic

Posted

Hi Haggis, getting a couple of bugs on Arch:

First off, line 245 is emitting an error 'Command "arch" not found'. Quick Google tells me that Arch Linux doesn't have an arch command, you might have to use "uname -m" instead.

Second, line 61 which greps for the "-release" files doesn't work right. It lists the contents of /etc okay, but seems to get stuck searching my entire home directory for something. Quick check seems that its trying to run the command:

[code]
grep -r -e -l -e -a -s -e
[/code]

I've seen this before with grep, and I think it might be a bug thats there for historical reasons or something. Either way, the fix would be to use 'grep "\-release"' instead. The backslash stops grep from bugging out.

Here's the patch for the bugs, tested on Arch only, so others will need to test for their own OS...

[code]
*** stats.sh 2012-12-23 23:59:10.000000000 +0000
--- copy of stats.sh 2013-01-06 22:54:01.409394805 +0000
***************
*** 58,64 ****
# Print a pretty logo for the Linux distribution the user is running.
function print_logo
{
! exists=`ls /etc/ | grep "-release" | wc -l`
if [ "$exists" -gt "0" ]; then
#if [ -e /etc/*-release ]; then
id="$(cat /etc/*-release | grep -E '^ID[ ]*=[ ]*[A-Za-z]+[ ]*' | cut -d '=' -f 2)"
--- 58,64 ----
# Print a pretty logo for the Linux distribution the user is running.
function print_logo
{
! exists=`ls /etc/ | grep "\-release" | wc -l`
if [ "$exists" -gt "0" ]; then
#if [ -e /etc/*-release ]; then
id="$(cat /etc/*-release | grep -E '^ID[ ]*=[ ]*[A-Za-z]+[ ]*' | cut -d '=' -f 2)"
***************
*** 242,248 ****
res=$(xdpyinfo | grep dimensions | awk {'print $2'})
load=$(uptime | awk -F 'load average:' '{ print $2 }')
# AFAIK there is no standard identification strings between CPU architectures.
! case $(arch) in
x86_64|i386|i486|i586|i686)
cpu="$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | cut -d ':' -f 2-)"
;;
--- 242,248 ----
res=$(xdpyinfo | grep dimensions | awk {'print $2'})
load=$(uptime | awk -F 'load average:' '{ print $2 }')
# AFAIK there is no standard identification strings between CPU architectures.
! case $(uname -m) in
x86_64|i386|i486|i586|i686)
cpu="$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | cut -d ':' -f 2-)"
;;
[/code]

Also, I have made for myself a PKGBUILD for this script so that I could install your script into the Arch package system. Would you like me to submit it as an [url="http://aur.archlinux.org"]AUR[/url] package that all Arch users can install and run it as the command "haggis-stats"?
1 person likes this

Share this post


Link to post
Share on other sites

Posted

[quote name='Majesticmerc' timestamp='1357514223' post='595437172']
First off, line 245 is emitting an error 'Command "arch" not found'. Quick Google tells me that Arch Linux doesn't have an arch command, you might have to use "uname -m" instead.
[/quote]

I admit, that bug was introduced in a patch I submitted a while back. I do not run Arch Linux, and, therefore, didn't test my patch against it. I do find it slightly ironic that Arch Linux doesn't ship the [i]arch[/i] utility, if for no other reason than their namesake!

Share this post


Link to post
Share on other sites

Posted

Hey guys i have a problem

the lsb-release package is not on all distros so i need your help

can you post the output of

[CODE]
cat /etc/issue
[/CODE]

and also tell me the Distro your running

Share this post


Link to post
Share on other sites

Posted

archlinux
[CODE]
Arch Linux \r (\l)
[/CODE]
1 person likes this

Share this post


Link to post
Share on other sites

Posted

[quote name='Haggis' timestamp='1357556741' post='595437798']can you post the output of
[CODE]
cat /etc/issue
[/CODE][/quote]

[code]Ubuntu 12.04.1 LTS \n \l[/code]
Ubuntu Server.

[code]This is \n.\O (\s \m \r) \t[/code]
Gentoo's default, although I've long since changed it.

Share this post


Link to post
Share on other sites

Posted

ok so cant rely on /etc/issue either lol

Max does my script pick up Gentoo ok?

Share this post


Link to post
Share on other sites

Posted

[quote name='Haggis' timestamp='1357560214' post='595437848']Max does my script pick up Gentoo ok?[/quote]

Works for the most part, a few errors at the beginning, but it's not running an X server or DE either like my previous posts. (No lsb_release, xdpyinfo or mate-session.) Displays the Tux penguin for its ASCII art. The OS field comes up as blank however.

Share this post


Link to post
Share on other sites

Posted

hmmmm i remember now lol

Share this post


Link to post
Share on other sites

Posted

One more, finally got around to toying with the latest release. (Fine, I'll use one of these new fangled graphical thingies instead of my usual consoles.)
[code]Chakra Linux (2013.01.03 - Claire) \r (\n) (\l)[/code]

[code]./stats.sh: line 245: arch: command not found


.88888888:.
88888888.88888.
.8888888888888888.
888888888888888888
88| _`88|_ `88888
88 88 88 88 88888
88_88_::_88_:88888
88:::,::,:::::8888
88`:::::::::``8888
.88 `::::` 8:88.
8888 `8:888.
.8888` `888888.
.8888:.. .::. ...:`8888888:.
.8888.| :| `|::`88:88888
.8888 ` `.888:8888.
888:8 . 888:88888
.888:88 .: 888:88888:
8888888. :: 88:888888
`.::.888. :: .88888888
.::::::.888. :: :::`8888`.:.
::::::::::.888 | .::::::::::::
::::::::::::.8 | .:8::::::::::::.
.::::::::::::::. .:888:::::::::::::
:::::::::::::::88:.__..:88888:::::::::::`
``.:::::::::::88888888888.88:::::::::`
``:::_:` -- `` -`-` ``:_::::``


OS: Chakra Linux
Hostname: vm12
Uptime: 17 minutes
CPU:Unknown
RAM (used / total): 477 / 2006 Mb
Desktop Enviroment: KDE 4.9.5
Logged in as: maxnorris
Kernel: 3.6.6-1-CHAKRA
Resolution: 1680x944 pixels
Load Averages: 0.63, 0.53, 0.23
Top Process (by memory use): kdeinit4:[/code]

This run didn't pick up the CPU, even though /proc/cpuinfo has correct info. (*shrug* it's a VM, but it picked it up with other distros properly.)

Share this post


Link to post
Share on other sites

Posted

ok so what does this give you

[CODE]
cat /proc/cpuinfo | grep 'model name
[/CODE]

Share this post


Link to post
Share on other sites

Posted

[quote name='Haggis' timestamp='1357570610' post='595438114']ok so what does this give you
[CODE]
cat /proc/cpuinfo | grep 'model name[/CODE][/quote]

[code][maxnorris@vm12 ~]$ cat /proc/cpuinfo | grep 'model name'
model name : Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz
model name : Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz[/code]

Share this post


Link to post
Share on other sites

Posted

Any chance of making this Apple / Mac OS X friendly? Apple logo and such?

Share this post


Link to post
Share on other sites

Posted

Despite the fact that OS X and GNU/Linux are both UNIX-ey, most of the stuff that Haggis implemented in the script are actually Linux specific. For example, OS X has no [i]/proc/cpuinfo[/i] or [i]lsb_release[/i] (Linux Standard Base release information).

Also, the script is implemented in BASH. While virtually every modern Linux distribution has BASH 4.0 or greater, OS X is stuck on the ancient BASH 3, which doesn't have many of the BASHisms modern scripts rely on. (For example, I have BASH 4.2 on Debian 7, but even Debian 6 has 4.1.)

That said, I didn't write the script; Haggis did. Its up to him whether he wants to support it. Although, if you patched it to work on OS X and submitted the diff, he would probably be willing to accept it.
1 person likes this

Share this post


Link to post
Share on other sites

Posted

Aren't there Mac OS X alternatives to accomplish the same tasks perhaps an alternative script as a port or something is in order; something could use "awk", "grep", and "tail" and such against "uname" and such to aquire info? Or against "system_profiler | more"

Share this post


Link to post
Share on other sites

Posted

By the way...

[CODE]
Ryans-MacBook-Air:~ ryan$ uname -a
Darwin Ryans-MacBook-Air.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
Ryans-MacBook-Air:~ ryan$ bash -version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.
Ryans-MacBook-Air:~ ryan$
[/CODE]

Share this post


Link to post
Share on other sites

Posted

Hey man, forgot to test this earlier but it seems to work well. Nice job. Great script. :)

[url="http://i.imgur.com/pmNlQA6.jpg"][img]http://i.imgur.com/pmNlQA6l.jpg[/img][/url]
1 person likes this

Share this post


Link to post
Share on other sites

Posted

Glad you like it

As per above only issue i have with making it work on MAC etc is i have no way of testing it

Still working on making it better and more sleek too

Share this post


Link to post
Share on other sites

Posted

Removed

Share this post


Link to post
Share on other sites

Posted

Hey man, forgot to test this earlier but it seems to work well. Nice job. Great script. :)

pmNlQA6l.jpg

 

What script is that you were running here? Is the 1st terminal an Arch linux thing, or script? (Or is that Haggis Script?)

Share this post


Link to post
Share on other sites

Posted

What script is that you were running here? Is the 1st terminal an Arch linux thing, or script? (Or is that Haggis Script?)

I am fairly sure it is glances.

2 people like this

Share this post


Link to post
Share on other sites

Posted

I am fairly sure it is glances.


The one on the right is version 1of my stats script

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.