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


[root@vhost1111 idcuser]# echo $PATH

Contents of init.sh

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

. /etc/rc.d/init.d/functions
case "$1" in
echo -n "Starting oversip: "
oversip $PID
touch /var/lock/subsys/oversip
echo -n "Shutting down oversip ??: "
killproc oversip
rm -f /var/lock/subsys/oversip
status oversip
if [ -f /var/lock/subsys/oversip ]; then
$0 stop
$0 start 
$0 stop
$0 start
echo "destroy existing connections during a restart."
echo "Usage: $0 {start|stop|restart|status}"
exit 1
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)
  • 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. – a CVn Jul 23 '13 at 9:02

Your init script tells you

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

Your shell tells you

# which oversip

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

  • 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

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

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