This really depends. If program.py
is supposed to finish then go on to xdotool
then you might want to use &&
instead of &
. A single &
means you want the command to execute then move on to the next command as soon as possible without waiting for it to finish. A dobule &&
means you want to wait for the execution to be done, then only continue if you have a zero error exit. You could also just remove the &
or use ;
if you want to run the next command regardless of program.py
's success. Here's what I'm getting at:
#!/bin/bash
cd ~/Folder
python program.py &&
WID=$(xdotool search --onlyvisible program)
...
If program.py
is supposed continue run while you run the xdotool
command, but you need program.py
to come to some ready state before you continue, then you're right in using &
, but you need to monitor the program.py
somehow, and get a signal from it that it is ok to continue. An ancient way of doing this is to simply let program.py
create/touch/edit a file, and when that file is detected you continue. A more advanced way would be to use network sockets or similar, but I'd advice against it if you really don't need to do anything fancy. Anyway, if you make program.py
create a signal file, say /tmp/.program_signalfile
, when things are ready all you have to do is:
#!/bin/bash
cd ~/Folder
python program.py &
until [ -f /tmp/.program_signal_file ]
do
sleep 1
done
WID=$(xdotool search --onlyvisible program)
rm /tmp/.program_signal_file
...
In this last solution program.py
and xdotool
are both running at the same time. If that's what you were looking for.