FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Development

 
 
LinkBack Thread Tools
 
Old 05-02-2010, 08:52 AM
"Berry, Randall"
 
Default Question about bash wrapper script

Hi,
I have an application I am working on that requires a config file in
the users home directory. This file is .asoundrc (alsa sound config) I
need to write a script that does 5 things.

1 ) check if the file is installed already (go to step 2 else go to
step 3)
2 ) install the file if it is not there (go to step 4)
3 ) Open the file and check for parameters. (go to step 4 else go to
step 5)
4 ) If parameters are missing then append them to the file. (go to step 5)
5 ) If all checks out launch the application (end)

I've gotten all but step 3 and step 4 to work so far but I don't know
how to tell bash to check for the needed parameters in an existing file
and if not there append them. I don't want to just open for append
because then it will just create a massive file over time as they are
added each time the program is run and I don't want to overwrite the
users file if it already exists, thus breaking something else the user
may have installed.

Also, is there a way to check the users sound device? I have it hard
coded right now for sound device 0. It would be nice if it could prompt
for device number in case the user has more than one device or if for
some other reason the device number is not 0.

Hopefully this makes sense to someone it's hard getting these thoughts
from inside my gray matter to paper.

Thanks,
Randy
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
 
Old 05-02-2010, 10:03 AM
Davide Bolcioni
 
Default Question about bash wrapper script

On Sunday 02 May 2010 10:52:57 Berry, Randall wrote:

> I have an application I am working on that requires a config file in
> the users home directory. This file is .asoundrc (alsa sound config) I
> need to write a script that does 5 things.

Assuming the format is the same format used in /etc/asound.conf, what you
need is known as a "parser" and you need one which can be invoked from bash.

> I've gotten all but step 3 and step 4 to work so far but I don't know
> how to tell bash to check for the needed parameters in an existing file
> and if not there append them.

There is a project for writing configuration file parsers

<http://augeas.net/>

but it does not seem to include one for .asoundrc. A quick Google search
turned up nothing. The functionality you need is probably available through
the Alsa library, but I suspect this would require some C programming.

You might find more helpful advice in the pages of the Alsa project

<http://www.alsa-project.org/main/index.php/Main_Page>

including where to ask the above question again.

Davide Bolcioni
--
There is no place like /home.
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
 
Old 05-02-2010, 10:58 AM
yersinia
 
Default Question about bash wrapper script

On Sun, May 2, 2010 at 12:03 PM, Davide Bolcioni
<dblistsub-fedora@yahoo.it> wrote:
> On Sunday 02 May 2010 10:52:57 Berry, Randall wrote:
>
>> * I have an application I am working on that requires a config file in
>> the users home directory. This file is .asoundrc (alsa sound config) I
>> need to write a script that does 5 things.
>
> Assuming the format is the same format used in /etc/asound.conf, what you
> need is known as a "parser" and you need one which can be invoked from bash.
>
>> * I've gotten all but step 3 and step 4 to work so far but I don't know
>> how to tell bash to check for the needed parameters in an existing file
>> and if not there append them.
>
> There is a project for writing configuration file parsers
>
> *<http://augeas.net/>
>
> but it does not seem to include one for .asoundrc. A quick Google search
> turned up nothing. The functionality you need is probably available through
> the Alsa library, but I suspect this would require some C programming.
Naturally there is nothing against to contribuite to auges in first
place if inclined.
--
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
 

Thread Tools




All times are GMT. The time now is 07:44 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org