Results 1 to 4 of 4

Thread: What is wrong with this script?

  1. #1
    Join Date
    Feb 2011
    Beans
    3

    What is wrong with this script?

    Below is my shell script

    Code:
    #!/bin/bash                                                                                                                                                                                                                                   
    
    # Report disc space usage script                                                                                                                                                                                               
    if [ $# -lt 1 ]
    then
        echo "You must pass at least one username to the $0 script."
        exit
    fi
    
    cd /home/$1
    
    SPACE='du -s'
    
    echo "$1 is using $SPACE of drive space."
    When I enter

    ./scriptname.sh username

    it returns

    username is using du -s of drive space

    I am running Ubuntu Server 10.10

  2. #2
    Join Date
    Feb 2010
    Location
    Silicon Valley
    Beans
    1,898
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: What is wrong with this script?

    To do command substitution, use $() or backticks:
    Code:
    SPACE=$(du -s)
    SPACE=`du -s`

  3. #3
    Join Date
    Feb 2011
    Beans
    3

    Re: What is wrong with this script?

    Thank you!

  4. #4
    Join Date
    Feb 2008
    Location
    Pelican Bay Correctional
    Beans
    Hidden!

    Question Re: What is wrong with this script?

    I am a dork.

    n/m this reply.
    Last edited by Habitual; February 8th, 2011 at 02:46 AM.
    What's a landing but a take off in reverse?
    Linux is just "DOS on 'steroids"

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •