PicoprobeのBUSIDを検索してWSLにAttachするスクリプト
タイトルママ。
シェルスクリプトを初めて書きました。
#!/bin/sh ESC=$(printf '\033') LIST=`usbipd.exe wsl list` LINE=`echo "$LIST"|grep Picoprobe` if [ $? = 1 ]; then echo "${ESC}[31mERROR:Picoprobe is not connected${ESC}[m" exit fi STATUS=`echo "$LINE"|grep "Not attached"` if [ $? = 1 ]; then echo "${ESC}[31mERROR:Picoprobe is already attached${ESC}[m" exit fi BUSID=`echo "$LINE"|awk '{print $1}'` echo "Picoprobe BUSID:$BUSID" usbipd.exe wsl attach --busid $BUSID
出力
# 正常時 Picoprobe BUSID:6-4 # Picoprobeが接続されていないとき ERROR:Picoprobe is not connected # PicoprobeがすでにAttachされているとき ERROR:Picoprobe is already attached