Acquire the list of available devices before starting Appium session

I have a remote machine with many iOS and Android devices connected to it through USB. My tests are executing on another machine and speaking to Appium server on that first machine. From my tests I’d like to obtain the list of available (connected to that machine) Android and iOS devices so that then I could start Appium session and begin my tests iterating over the devices. What I’d like Appium server to do, is execute adb devices for Android and instrumets -s devices for iOS and return this information to me. Can it do that? If no, what would be the best way to get this information?