You can use aconnectgui if you don't want to use qjackctl.
Also, you can use the device name with aconnect. Here's an excerpt of a script I rote to start Pd on my wearable 10 years ago. The trick is that you need to wait until Pd sets up its MIDI ports before trying to connect to them in a script.
-----
echo "rc_starts_pd: strating pd"
pd -rt -nogui -alsa -audiodev 4 -audiobuf 10 -alsamidi $PATCH &
# wait for pd to initialize
KA=$(aconnect -i -o | grep "Pure Data")
while [ "$KA" = "" ]
do
sleep 1
echo "rc_starts_pd: pd alsamidi not ready"
KA=$(aconnect -i -o | grep "Pure Data")
done
echo "rc_starts_pd: pd alsmidi is ready"
# connect the UA-25 midi to Pure Data
echo "rc_starts_pd: alsa midi connect 'UA-25' <-> 'Pure Data'"
aconnect 'UA-25' 'Pure Data'
aconnect 'Pure Data':1 'UA-25':0
-----
Date: Fri, 30 Nov 2018 16:47:21 +0100From: "Ingo" <ingo@miamiwave.com>To: "'Jaime Oliver'" <jaime.oliver2@gmail.com>Cc: "'Pd-List'" <pd-list@lists.iem.at>Subject: Re: [PD] Recognizing USB MIDI interfaces on Pd 0.48.1 (Debian 9.5)Message-ID: <002b01d488c3$fb7c13c0$f2743b40$@miamiwave.com>Thanks, Jamie!got it finally to connect or disconnect now.I didn't have the correct client and ID numbers.I'll have to find a way to retrieve the port number of an unknown USB interface first automatically before I can connect it to Pd automatically.I couldn't find any way to connect an existing new port without knowing its number.I tried aconnect *:0 128:0 instead of aconnect 24:0 128:0 but it didn't work.Obviously havin * become 128 would cause a feedback loop - so it makes sense not to work.I had also installed qjackctl as IOhannes suggested.This also works.