diff --git a/rsselector.sh b/rsselector.sh
index 72e4fe71ff0891a725abe8223f7d156e095e389f..c6ba09f339575d8f699a1b020c02dc928d6127f8 100644
--- a/rsselector.sh
+++ b/rsselector.sh
@@ -7,6 +7,18 @@
 # Author: Carmelo Pellegrino <carmelo.pellegrino@bo.infn.it>
 #
 
+function put_lock() {
+  touch /tmp/auto_ss
+}
+
+function rm_lock() {
+  unlink /tmp/auto_ss
+}
+
+function test_lock() {
+  return [ -e /tmp/auto_ss ]
+}
+
 function createList() {
   local LIST
   local file
@@ -105,6 +117,7 @@ JGetMessage -H localhost -T MSG -d 3 >${daq_log_file} &
 ## impl: get the pid and add to the list of must_kill_at_the_exit
 
 # Copy selected run setup file, changing the run number
+cat ${rs_file} | sed -e 's/RUNNUMBER/${run_number}/' >dm.detectorfile
 
 run_start_time=`nowUTC`
 
@@ -112,10 +125,17 @@ run_start_time=`nowUTC`
 dm_driver ${run_duration} | mono DetectorControl.exe --control --reset &
 
 # Launch the DAQ
+log "Launching the DAQ with the following command line: daq.sh ${run_number} ${run_start_time} ${run_duration}"
 daq.sh ${run_number} ${run_start_time} ${run_duration}
 
 # Point the browser to the correct address, if required
 zenity --question \
        --text="Would you like to open the DetectorManager GUI?" \
-       --cancel-label="No, thanks" && firefox http://localhost:1301/
+       --cancel-label="No, thanks" && firefox http://localhost:1301/ &
+
+# Wait the end of the run
+sleep ${run_duration}
+
+zenity --info --text="Run ${run_number} finished!"
 
+exit 0