See example
lsof -PFp -w /dev/ttyUSB0 || avrdude -c arduino -p atmega2560 -cwiring -P /dev/ttyUSB0 -b115200 -D -Uflash:w:"/home/a/Documents/TirBoxProj/supervisor/FreeRTOS/Demo/FreeRTOS_ATmega2560_MPLAB.X/dist/default/production/FreeRTOS_ATmega2560_MPLAB.X.production.hex"
here I try to get lsof output. If no output so tty isn't busy. If tty isn't busy, lsof return not 0, so I can use || to check.
I also want to use variable instead of use /dev/ttyUSB0 twice. I try
export t="/dev/ttyUSB0" && lsof -PFp -w ${t} || avrdude -c arduino -p atmega2560 -cwiring -P ${t} -b115200 -D -Uflash:w:"/home/a/Documents/TirBoxProj/supervisor/FreeRTOS/Demo/FreeRTOS_ATmega2560_MPLAB.X/dist/default/production/FreeRTOS_ATmega2560_MPLAB.X.production.hex"
but it doesn't work in MPLAB (Execute this line after build). But works well in linux console Why?
See example
lsof -PFp -w /dev/ttyUSB0 || avrdude -c arduino -p atmega2560 -cwiring -P /dev/ttyUSB0 -b115200 -D -Uflash:w:"/home/a/Documents/TirBoxProj/supervisor/FreeRTOS/Demo/FreeRTOS_ATmega2560_MPLAB.X/dist/default/production/FreeRTOS_ATmega2560_MPLAB.X.production.hex"here I try to get lsof output. If no output so tty isn't busy. If tty isn't busy, lsof return not 0, so I can use || to check.
I also want to use variable instead of use /dev/ttyUSB0 twice. I try
export t="/dev/ttyUSB0" && lsof -PFp -w ${t} || avrdude -c arduino -p atmega2560 -cwiring -P ${t} -b115200 -D -Uflash:w:"/home/a/Documents/TirBoxProj/supervisor/FreeRTOS/Demo/FreeRTOS_ATmega2560_MPLAB.X/dist/default/production/FreeRTOS_ATmega2560_MPLAB.X.production.hex"but it doesn't work in MPLAB (Execute this line after build). But works well in linux console Why?