I am able to run instrument using command line for a single device / simulator, but I need to run it on two devices. Manually I can achieve this by opening two new window of
Another way to achieve it is to open two separate instance of Instrument and execute it
I struggled with this as well here is a part of my solution. What i did is:
Create trace files in instruments with you script .js file pre selected and save it to disk.
Reads the UDID of all connected devices. Loop trough all connected devices and replace the UDID in your trace file with the currenct UDID. In the same loop open instruments.
for line in $(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'); do
UDID=${line}
file$x $(replace 345w67ww89ww0w98w762wewq33e2 with ${UDID})
open -a Instruments /PATH/TO/TRACE/file$x
done
This solution will open multiple windows of Instruments. You can go trough them with appleScript to click the record button.