LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   transport endpoint is not connected & if statement (https://www.linuxquestions.org/questions/linux-newbie-8/transport-endpoint-is-not-connected-and-if-statement-919329/)

ted_chou12 12-18-2011 09:08 AM

transport endpoint is not connected & if statement
 
Hi, my hdd sometimes disconnects from the nas by itself, that doesnt bother me. What I want is to write a script to test it:
Code:

# ls /usb/sdb1/
ls: /usb/sdb1/: Transport endpoint is not connected

This shows up when the hdd disconnects, I wonder if how I can use an if statement to get it:
Code:

output=$(ls /usb/sdb1/)
echo "$output"
if [ "$output" == "ls: .: Transport endpoint is not connected" ] ; then
        echo "yes"
fi

But there are no outputs.
Thanks,
Ted

ted_chou12 12-18-2011 09:19 AM

Thanks, I found out how:
Code:

output="$(ls "/usb/sdb1/" 2>&1)"
if [ "$output" == "ls: /usb/sdb1/: Transport endpoint is not connected" ] ; then
        echo "yes"
fi



All times are GMT -5. The time now is 06:08 PM.