A config file in /etc is just another "data" file.

Your problem has nothing to do with Perl itself, as it seems. You need to
look up how to configure your web server to allow suexec for a script. And,
normally, it is not a good idea to let the webserver edit files in /etc,
but you'll probably know that already. :-)

            -- Eric

Alpesh Naik <naik.alp...@gmail.com> wrote on 07/09/2009 12:23:54 PM:

> From:
>
> Alpesh Naik <naik.alp...@gmail.com>
>
> To:
>
> Eric Veith/Germany/i...@ibmde
>
> Date:
>
> 07/09/2009 12:23 PM
>
> Subject:
>
> Re: Edit a config file using perl cgi script
>
> Thanks for the reply,
>
> but i m not talking about data files,
> i want to edit the config file of /etc folder and when i m running
> script from browser i have only read only access to that particular file.
>
> now how can i run script as root user to edit that file.
>
> Please help,
> Regards,
> Alpesh

> On Thu, Jul 9, 2009 at 3:37 PM, Eric Veith <erve...@de.ibm.com> wrote:
> sudo perl -e 'open($fh, "<", "/tmp/foo"); @f = <$fh>; close($fh); open
($fh,
> ">", "/tmp/foo"); foreach(@f) { s/^(Key1=).*/$1NewValue1/; print $fh
$_; }
> close($fh);'
>
> As always, TIMTOWTDI.
>
> HTH,
>            -- Eric,
>
> Alpesh Naik <naik.alp...@gmail.com> wrote on 07/09/2009 11:34:43 AM:
>
> > From:>
> >
> > Alpesh Naik <naik.alp...@gmail.com>
> >
> > To:
> >
> > beginners@perl.org
> >
> > Date:
> >
> > 07/09/2009 11:35 AM
> >
> > Subject:
> >
> > Edit a config file using perl cgi script
> >
> > Hi,
> >
> > I need to edit a config file using perl cgi  script. i.e., Search with
> the
> > 'key' string and edit the 'value'.
> >
> > For eg: below is what I have in the config file "configfile.cfg".
> >
> > Key1=OldValue1
> > Key2=OldValue2
> >
> > I want to search for "Key1" and change "OldValue1" to "NewValue1"
> >
> > *(Note that, permission of config file is 600, i want to edit the file
> > without changing permissions)*
> >
> > Thanks and Regards,
> > Alpesh


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to