bash script not working as expected when executed at startup
I have the following test script that does not behave as I would expect when I try starting it at boot. My overall script is larger, but this is the essence of the issue at hand. What it is doing is turning on a light (just to verify the script is running), waiting a few seconds, starting a co-process for linphonec, a CLI based SIP phone client, and then sends the "call" command to the co-process for linphone to dial (my cell number replaced with a fake number).
Code:
#!/bin/bash Code:
/usr/local/bin/test.sh & Code:
root 1936 1 0 15:26 ? 00:00:00 /bin/bash /usr/local/bin/test.sh Code:
SHELL=/bin/bash So how can I get this script to operate correctly at startup? I am sure it has something to do with shells and how they behave, but I do not know much about this. |
Bootup script is not running in your user environment, there is no $PATH set, no executables will be found. Meaning if you try to execute foo it wont' be found, you need to execute /full/path/to/foo.
|
Quote:
|
When I wanted to do this recently I just used cronjob/crontab and put a ./Path/To/Script in the config file.
Hope this helps :) -Fergus |
Quote:
Is there anything special about Code:
echo "call 5555555555" >&"${COPROC[1]}" One thing could be that the PBX (IncrediblePBX) that is running on the board has not started fully by the time the script runs, this no call. Would me adding a sleep in the cronjob still allow for the PBX to startup? |
Quote:
quick glance, i'd say: gpio, coproc. |
If you have the environment all set up in your root user home directory, you could try to include your bash profile to the beginning of the script. Try to include the '.bashrc' and/or '.profile' from your home directory.
Code:
. /root/.bashrc Code:
. /root/.profile |
I finally figured out the issue. After I figured out how to generate logs on linphonec, I notice the following on the first line when run from putty:
Code:
ortp-message-Using (r/w) config information from /root/.linphonerc Code:
ortp-message-Using (r/w) config information from (null)/.linphonerc Thanks everyone! |
coproc is a builtin bash command (as of version 4).
Did you create a proper root account or are you logging in as the default user pi? Did you create the cronjob as root or pi? About the only thing I can think of at the moment is that you might want to specify the configuration file in the script. Code:
coproc linphonec -c /path/to/.linphonec |
All times are GMT -5. The time now is 11:28 AM. |