Return error code of command executed by sudo
Status: Alpha
Brought to you by:
rgruber
The following script works with sudo:
#!/bin/bash
# Return code example
if sudo mount /mnt/test /dev/mapper/loop0
then
kdialog --msgbox "Mounted."
else
kdialog --msgbox "Mount failed."
fi
if using kdesudo it does not work because kdesudo does not return the errorcode from the command executed, it only checks for strings returned by sudo.
#!/bin/bash
# Return code example
if kdesudo -u root mount /mnt/test /dev/mapper/loop0
then
# executed always
kdialog --msgbox "Mounted."
else
kdialog --msgbox "Mount failed."
fi