LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-26-2014, 09:21 PM   #16
VideoTrack
LQ Newbie
 
Registered: Mar 2014
Posts: 17

Original Poster
Rep: Reputation: Disabled

Thanks grail, the second one I am calling the script from a C program

The account name I am logged into is 'transcend', and if I start the process from 'transcend' account, it works

The application has to run autonomously, and is automatically started by Crunchbang when the system is booted.

After a reboot, when I type ps -Af I see my process running as root

When the system starts from a cold boot, my application process starts fine,and I can see it in pstree, but when it needs to call the script, it gives the PulseAudio error

I hope this detail describes what you are looking for
Many thanks
VideoTrack
 
Old 03-26-2014, 09:33 PM   #17
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
i think putting it in the /etc/rc.local file is the correct way to do it but you can also try putting the script in trancends crontab using the @reboot declarative.
 
Old 03-26-2014, 09:35 PM   #18
VideoTrack
LQ Newbie
 
Registered: Mar 2014
Posts: 17

Original Poster
Rep: Reputation: Disabled
Unhappy

Quote:
Originally Posted by schneidz View Post
i am confused as well. a few posts ago, op mentioned of calling the bash script from within a c-program using execvp(). which is kinda' strange (but not impossible) considering most of the time people create shell scripts to call c-programs.

I would be that similar to running it in cron only a limited set of environment variables are invoked therefore its not passing everything.
Hello schneidz, thanks and I understand your confusion.

I had been trying to call the aplay directly from the program but always got the Pulse Audio error. So I decided to call a script from the program instead as a way of attempting to put debug statements in the script and find out what the problem is. However, when I finally got the script to work, I find that aplay still gives me the same error!! - So I am actually back to square one

Thanks everyone for your continued excellent support, it is appreciated.
VideoTrack

Last edited by VideoTrack; 03-26-2014 at 09:36 PM.
 
Old 03-26-2014, 09:39 PM   #19
VideoTrack
LQ Newbie
 
Registered: Mar 2014
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
i think putting it in the /etc/rc.local file is the correct way to do it but you can also try putting the script in trancends crontab using the @reboot declarative.

Does that mean the 'test_script' file should be moved to /etc/rc.local instead?
 
Old 03-26-2014, 09:40 PM   #20
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
no, i assumed that was the way you were having it run automatically at system start up.
 
Old 03-26-2014, 09:56 PM   #21
VideoTrack
LQ Newbie
 
Registered: Mar 2014
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
no, i assumed that was the way you were having it run automatically at system start up.
I have 7 files in startup / shutdown (not sure if this correct terminology), they are links to the (script) file that starts the actual program
doing ls -l on the folders, I think the ones you need to know about are:
/etc/rc2.d/ S06mqserver -> /usr/mms/com/mqserver
/etc/rc3.d/ S06mqserver -> /usr/mms/com/mqserver
/etc/rc4.d/ S06mqserver -> /usr/mms/com/mqserver
/etc/rc5.d/ S06mqserver -> /usr/mms/com/mqserver

/etc/rc0.d/ K01mqserver -> /usr/mms/com/mqserver
/etc/rc1.d/ K01mqserver -> /usr/mms/com/mqserver
/etc/rc6.d/ K01mqserver -> /usr/mms/com/mqserver

Does this help?

Thanks
VideoTrack

Last edited by VideoTrack; 03-26-2014 at 10:14 PM.
 
Old 03-26-2014, 10:32 PM   #22
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Ok, been a while since I looked at this form of init scripts, but if I remember correctly, the lower the number the earlier something is executed. So my guess would be that you have set this too early and PulseAudio is not currently started by the time your script / command is executed.

What happens if you change the number to something like 99 so it is one of the last things to run?

Sorry if I am way off base here :$
 
Old 03-26-2014, 11:04 PM   #23
VideoTrack
LQ Newbie
 
Registered: Mar 2014
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
Ok, been a while since I looked at this form of init scripts, but if I remember correctly, the lower the number the earlier something is executed. So my guess would be that you have set this too early and PulseAudio is not currently started by the time your script / command is executed.

What happens if you change the number to something like 99 so it is one of the last things to run?

Sorry if I am way off base here :$
Hi grail, thanks for your further efforts. That would not appear to be the case. It is many minutes before my app calls the script, and PulseAudio is definitely running. Additionally, the error is a 'connection refused' message.
Looking in ps -Af I do see Pulse Audio listed, here is the some of the output, if that helps:

I notice that pulseaudio is running under 1000 and my app is running under root. Could that be the problem?

Code:
UID        PID  PPID  C STIME TTY          TIME CMD
root      2374     1  0 12:06 ?        00:00:00 /usr/mms/exe/advantech_radio_dvr 110 /usr/mms/cfg/RadioDvr
root      2375     1  0 12:06 ?        00:00:00 /usr/mms/exe/log_file_mngr -p /usr/mms/out -e out -f 10 -M 10 radio_dvr
root      2376     1  0 12:06 ?        00:00:01 /usr/mms/exe/device_server /usr/mms/cfg/DeviceServer
root      2377     1  0 12:06 ?        00:00:00 /usr/mms/exe/log_file_mngr -p /usr/mms/out -e out -f 10 -M 10 device_server
root      2378     1  0 12:06 ?        00:00:00 /usr/mms/exe/pseudo_sign_dvr 24 /usr/mms/cfg/PseudoDvr
root      2379     1  0 12:06 ?        00:00:00 /usr/mms/exe/log_file_mngr -p /usr/mms/out -e out -f 10 -M 10 pseudo_sign_dvr

1000      2545     1  0 12:07 ?        00:00:00 pnmixer
1000      2548     1  0 12:07 ?        00:00:03 thunar --daemon
1000      2592     1  0 12:07 ?        00:00:00 /usr/lib/xfce4/xfconf/xfconfd
1000      2595     1  0 12:07 ?        00:00:00 /usr/bin/pulseaudio --start
rtkit     2597     1  0 12:07 ?        00:00:00 /usr/lib/rtkit/rtkit-daemon
root      2602     1  0 12:07 ?        00:00:00 /usr/lib/upower/upowerd
1000      2704     1  0 12:07 ?        00:00:00 /usr/lib/i386-linux-gnu/gconf/gconfd-2
 
Old 03-26-2014, 11:41 PM   #24
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Quote:
I notice that pulseaudio is running under 1000 and my app is running under root. Could that be the problem?
It does sound plausible that root may not be able to take it over ... not 100% on that though.

Hopefully one of the other guys will have better knowledge on this part
 
Old 03-27-2014, 06:59 AM   #25
VideoTrack
LQ Newbie
 
Registered: Mar 2014
Posts: 17

Original Poster
Rep: Reputation: Disabled
I am confused, if I log in as transcend and launch my application, or the script, aplay runs PulseAudio without issues, even though PulseAudio is owned by mysterious process 1000.

If my application starts up as root, it cannot run aplay because of the Pulse Audio error

I thought root would have had maximum privileges, certainly more than my program?

Please, anybody?

Thanks
VideoTrack

Last edited by VideoTrack; 03-27-2014 at 01:57 PM. Reason: typo error
 
Old 03-27-2014, 02:33 PM   #26
VideoTrack
LQ Newbie
 
Registered: Mar 2014
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by VideoTrack View Post
I am confused, if I log in as transcend and launch my application, or the script, aplay runs PulseAudio without issues, even though PulseAudio is owned by mysterious process 1000.

If my application starts up as root, it cannot run aplay because of the Pulse Audio error

I thought root would have had maximum privileges, certainly more than my program?

Please, anybody?

Thanks
VideoTrack
I think I might know the root of the problem, but don't know how to resolve.
My application runs on a stand-alone embedded system and doesn't require to be logged on to operate.
My application starts at boot time.

Perhaps Pulse Audio is not running, or only runs as some sort of a 'user process' when the terminal is logged in.

I think I need pulse audio and maybe other sound related programs to start as root when the system is booted, rather than when a user logs in. I read articles advising against this, but my app is a standalone app running on an isolated embedded system. It monitors data on a COM port and needs to play a wav file under certain circumstances.

I am running Crunchbang O/S

ps -Af shows Pulse Audio running under a UID of 1000

My app runs as UID of root

This is the error message produced when my app calls aplay:
Code:
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

aplay: main:682: audio open error: Connection refused
Could this be related?

Last edited by VideoTrack; 03-27-2014 at 02:39 PM. Reason: added error message
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ath9k driver fails on Crunchbang after certain amount of time (Acer Aspire) Rainfly_X Linux - Hardware 2 11-24-2012 12:45 AM
[SOLVED] Script Fails maddyfreaks Linux - Newbie 7 05-02-2011 02:25 PM
What if a script inside another script fails to run? saiteju Programming 3 02-03-2010 12:35 AM
Shutdown script for Crunchbang Linux running from USB on Asus Surf 2G Maestro01 Linux - Laptop and Netbook 5 03-19-2009 12:11 PM
install script fails sycamorex Linux - Software 2 06-16-2007 05:28 AM


All times are GMT -5. The time now is 09:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration