I have a bash script to detect HDD connected in USB. I would like to convert it in python script to use it into SSH connection.
#!/bin/bash
for disk in /dev/sd?
do
        detect=$(udevadm info $disk | grep USB)
        if [[ "$detect" == *USB ]]; then
                echo "$disk is a USBDISK.."
        fi
done
I tried that, but it doesn't work. I have a problem with the for loop and with the condition in if statement :
import paramiko
for disk in "/dev/sd*" :
        CMD = 'udevadm info %s | grep USB' % disk
        stdin, stdout, stderr = client.exec_command(CMD, get_pty = True)
        detect = stdout.read()
        if detect == '*USB' :
            print "disk is a USBDISK.."
Thanks.
 
    