Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 21 Dec 2014, 11:13
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
[SOLVED] Script to write in .conf/text file.
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
Jejy69


Joined: 20 Jan 2011
Posts: 707
Location: Perpignan

PostPosted: Fri 12 Oct 2012, 12:49    Post_subject:  [SOLVED] Script to write in .conf/text file.
Sub_title: Thanks L18L
 

Hi !

Could someone help me create a script please ?

I would like, to integrate the text in a conf file, from a script with different options.
I know this is not well explained ...

I have a config file in / etc / xdg / lxsession / autostart.conf
Content =
Code:

@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash


Using a script, is it possible to add characters in the file, in a precise location?
For example, by running the script, once configured, I want the conf targeted file looks like this :

Code:
@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash
@hello world


Of course, if you have a base, I could then adapt.
It's because, I do not know programming, but I can understand the script. Confused

Thanks, if you have questions. Since mine is not really precise... Razz I don't know how to explain it.

Cheers !

_________________
I'm Commander Shepard and this is my favorite Linux distrbution on the Citadel.

Edited_time_total
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2620
Location: www.eussenheim.de/

PostPosted: Fri 12 Oct 2012, 13:08    Post_subject:  

is it possible to add characters in the file, in a precise location?

Easiest cases first

if you want just append
@hello world
to your file /etc/xdg/lxsession/autostart.conf (no spaces)
then
Code:
echo '@hello world' >> /etc/xdg/lxsession/autostart.conf

will do this Smile

or if hello world is the content of par example file1
then
Code:
cat file1 >> /etc/xdg/lxsession/autostart.conf

will do it

Inside, not at end?
use stream editor sed
Code:
sed --help

and/or
Code:
man sed
Back to top
View user's profile Send_private_message 
Jejy69


Joined: 20 Jan 2011
Posts: 707
Location: Perpignan

PostPosted: Fri 12 Oct 2012, 14:39    Post_subject:  

Thank you L18L, Smile

I tried with the 'echo' command, it helps me a lot!
Now, if does not bother you, I need again a few tips please Smile .

I have this.
Code:
@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash


I'd get it like this:
Code:
@xfce4-panel
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash


I tried with :
Code:
sed -n --line-length=1 -i[/etc/xdg/lxsession/LXDE/autostart]  -e=@xfce4-panel

But doesn't work Cool

It's to replace lxpanel with xfce4-panel, I'm sure I'm wrong in the line, but I do not know where exactly the script does not work.
My syntax is bad, I probably put the commands in the wrong places ...

_________________
I'm Commander Shepard and this is my favorite Linux distrbution on the Citadel.
Back to top
View user's profile Send_private_message 
L18L

Joined: 19 Jun 2010
Posts: 2620
Location: www.eussenheim.de/

PostPosted: Fri 12 Oct 2012, 14:58    Post_subject: Script to write in .conf file.
Sub_title: replace
 

replace
@lxpanel --profile LXDE
by
@xfce4-panel
in file /etc/xdg/lxsession/LXDE/autostart

Code:
sed -i 's/@lxpanel --profile LXDE/@xfce4-panel/' /etc/xdg/lxsession/LXDE/autostart


You might use variables?
Code:

BEFORE='@lxpanel --profile'
AFTER='@xfce4-panel'
sed -i "s/${BEFORE}/${AFTER}/" /etc/xdg/lxsession/LXDE/autostart

Note the double quotes because there are variables inside

Edited_times_total
Back to top
View user's profile Send_private_message 
Jejy69


Joined: 20 Jan 2011
Posts: 707
Location: Perpignan

PostPosted: Fri 12 Oct 2012, 15:04    Post_subject:  

Yeah ! So Cool, it's perfect !
Thanks you ! Smile Exactly what I wanted!

Very fast and efficient, thank you Very Happy

_________________
I'm Commander Shepard and this is my favorite Linux distrbution on the Citadel.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0537s ][ Queries: 12 (0.0031s) ][ GZIP on ]