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 ...
- 07-29-2008 #1Just 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 ?
- 07-29-2008 #2
nothing is printed when mount successfully executes, so nothing will be returned in the successful case in your script
- 07-29-2008 #3Linux 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


