Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i have installed oversip & when i try to execute the command "oversip" from shell,

[root@vhost1111 ~]# oversip
NOTICE: <executable> OverSIP 1.3.8 starting...

it gets executed. But when i put that command in a shell script and then run the shell script. It says command not found.

[root@vhost1111 ~]# ./init.sh start
Switch to user oversip
Starting oversip: ./init.sh: line 21: oversip: command not found

----Oversip Path----

[root@vhost1111 idcuser]# which oversip
/usr/local/rvm/gems/ruby-1.9.2-p320/bin/oversip

----$PATH-----

[root@vhost1111 idcuser]# echo $PATH
/usr/local/rvm/gems/ruby-1.9.2-p320/bin/oversip:
/usr/local/rvm/gems/ruby-1.9.2-p320/bin:
/usr/local/rvm/gems/ruby-1.9.2-p320@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-320/bin:
/usr/local/rvm/bin:/sbin:/bin:/usr/sbin:/usr/bin:/sbin/:/usr/bin/:/usr/sbin/:/usr/local/bin:/bin:/usr/local/sbin/:/usr/local/rvm/bin

Contents of init.sh

#!/bin/sh
PID="--pid /var/run/oversip/oversip.pid -u oversip";
if [ ! -d /var/run/oversip ]; then
mkdir -p /var/run/oversip
fi
if id -u oversip >/dev/null 2>&1; then
echo "Switch to user oversip";
else
adduser -u 106 -g 99 --shell /bin/false -b /var/run oversip
chown oversip /var/run/oversip 
fi

. /etc/rc.d/init.d/functions
case "$1" in
start)
echo -n "Starting oversip: "
oversip $PID
echo
touch /var/lock/subsys/oversip
;;
stop)
echo -n "Shutting down oversip ??: "
killproc oversip
echo
rm -f /var/lock/subsys/oversip
;;
status)
status oversip
;;
condrestart)
if [ -f /var/lock/subsys/oversip ]; then
$0 stop
$0 start 
fi
;;
reload|restart)
$0 stop
$0 start
echo "destroy existing connections during a restart."
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0

I added 'type oversip' and also 'which oversip' in the script: Below is the output for both.

./init.sh: line 20: type: oversip: not found
which: no oversip in (/sbin:/usr/sbin:/bin:/usr/bin)
share|improve this question
    
Where is the executable oversip ? (output which oversip) It looks like it is in the root PATH, but not in the PATH of user oversip. –  Levans Jul 23 '13 at 7:35
    
can you post the contents of init.sh or at least the line that calls oversip. also do this command which overship from your shell and tell us the results. –  booyaa Jul 23 '13 at 8:03
    
I have updated the question with the output of 'which oversip' and contents of $PATH. –  Ashish Jul 23 '13 at 8:44
    
And about the content of init.sh, and the $PATH of user oversip ? These are the relevant things here. –  Levans Jul 23 '13 at 8:49
1  
Try adding type oversip; which oversip immediately before echo -n "Starting oversip: " under start) in that script. I'm willing to bet it's a simple path issue, and that will confirm it. If so, it might be as simple as specifying the full path to the executable. (You might also want to echo $PATH and $LD_LIBRARY_PATH, the latter if the software requires any particular libraries of its own.) You may need to promote the script to use /bin/bash rather than /bin/sh for type to work, but I think you'll be OK as it is. –  Michael Kjörling Jul 23 '13 at 9:02

1 Answer 1

Your init script tells you

which: no oversip in (/sbin:/usr/sbin:/bin:/usr/bin)

Your shell tells you

# which oversip
/usr/local/rvm/gems/ruby-1.9.2-p320/bin/oversip

What directory do you think you need to add to the PATH in the init script?

PATH="$PATH:/usr/local/rvm...320/bin"
share|improve this answer
    
I added: export PATH=/usr/local/rvm/gems/ruby-1.9.2-p320/bin/:$PATH to the init script , but it is still not working. –  Ashish Jul 24 '13 at 6:55
    
When i check $PATH from init script it shows PATH contents as given in the updated question. But when i do which oversip, why does it show : no oversip in (/sbin:/usr/sbin:/bin:/usr/bin) , what is /sbin:/usr/sbin:/bin:/usr/bin ? ,as it dosent match with my $PATH contents. –  Ashish Jul 24 '13 at 7:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.