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 Wed 17 Sep 2014, 09:55
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 [5 Posts]  
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.
Subject description: 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.

Last edited by Jejy69 on Fri 12 Oct 2012, 15:10; edited 1 time in total
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

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: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Fri 12 Oct 2012, 14:58    Post subject: Script to write in .conf file.
Subject description: 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

Last edited by L18L on Fri 12 Oct 2012, 15:06; edited 3 times in 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 from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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