I have a question about rc.local. I created a script auto.sh and it includes:
#!/bin/sh
cd $home
source /opt/ros/indigo/setup.bash
xterm -hold -e "/opt/ros/indigo/bin/roscore" &
xterm -hold -e "/opt/ros/indigo/bin/roslaunch rosbridge_server rosbridge_websocket.launch"
exit 0My purpose is run to this script automatically using rc.local. rc.local file located at:
/etc/init.d/rc.localrc.local file includes the code :
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo ./auto.sh
sh '/home/moguztas/auto.sh'
exit 0This code is executable. I followed the steps at How can I make "rc.local" run on startup? .
But when I check the code using:
sudo /etc/init.d/rc.local startit gives a error in terminal as given below:
./auto.sh: 4: ./auto.sh: source: not foundAlso, in XTerm terminal errors are given like :error1error2
Could you tell what is my problem ?
41 Answer
You're invoking
/bin/sh, which, on Ubuntu, is a much simpler shell than/bin/bash, and lacks thesourcecommand.At the time
rc.localruns, is/opt/ros/indigo/mounted? If it is your encryptedHOMEdirectory, it won't exist until you log in.At the time
rc.localruns, the X server has not yet started, so running anxtermwon't work.