script.sh: source: not found

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 0

My purpose is run to this script automatically using rc.local. rc.local file located at:

/etc/init.d/rc.local

rc.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 0

This 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 start

it gives a error in terminal as given below:

./auto.sh: 4: ./auto.sh: source: not found

Also, in XTerm terminal errors are given like :error1error2

Could you tell what is my problem ?

4

1 Answer

  1. You're invoking /bin/sh, which, on Ubuntu, is a much simpler shell than /bin/bash, and lacks the source command.

  2. At the time rc.local runs, is /opt/ros/indigo/ mounted? If it is your encrypted HOME directory, it won't exist until you log in.

  3. At the time rc.local runs, the X server has not yet started, so running an xterm won't work.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like