Find the answer to your Linux question:
Results 1 to 3 of 3
i have a script (bourne shell ) .i have a partition /dev/sda1 var=$(mount /dev/sda1) echo $var But it is not printing anything ? iS there any way to get the ...
  1. #1
    Just Joined!
    Join Date
    Jul 2008
    Posts
    24

    [SOLVED] mount doent reurn anything

    i have a script (bourne shell ) .i have a partition /dev/sda1


    var=$(mount /dev/sda1)
    echo $var


    But it is not printing anything ? iS there any way to get the retuen value of mount ?

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    nothing is printed when mount successfully executes, so nothing will be returned in the successful case in your script

  3. #3
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    The output of a successful command is nothing

    What you want to do is check the return value. If it is zero, it is successful, if it is any other value there has been an issue. Given that you are running the command mount /dev/sda1 I assume the rest of the information is in /etc/fstab - I'll leave that part to you to manage.

    If you want to check the return value of the last command, you check the $?. This is the very last command run so it must be run immediately. If you want to store it in $var as you have above:
    Code:
    mount /dev/sda1
    var=$?
    echo $var

Posting Permissions

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