The time now is Fri 24 May 2013, 10:19
All times are UTC - 4 |
| Author |
Message |
Jejy69

Joined: 20 Jan 2011 Posts: 656 Location: Perpignan, Lego man, The Last Crusade...
|
Posted: 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.
Thanks, if you have questions. Since mine is not really precise... I don't know how to explain it.
Cheers !
_________________ Linux a un noyau, Windows a des pépins.
Last edited by Jejy69 on Fri 12 Oct 2012, 15:10; edited 1 time in total
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1718 Location: Burghaslach, Germany
|
Posted: 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
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
and/or
|
|
Back to top
|
|
 |
Jejy69

Joined: 20 Jan 2011 Posts: 656 Location: Perpignan, Lego man, The Last Crusade...
|
Posted: Fri 12 Oct 2012, 14:39 Post subject:
|
|
Thank you L18L,
I tried with the 'echo' command, it helps me a lot!
Now, if does not bother you, I need again a few tips please .
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
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 ...
_________________ Linux a un noyau, Windows a des pépins.
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1718 Location: Burghaslach, Germany
|
Posted: 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
|
|
 |
Jejy69

Joined: 20 Jan 2011 Posts: 656 Location: Perpignan, Lego man, The Last Crusade...
|
Posted: Fri 12 Oct 2012, 15:04 Post subject:
|
|
Yeah ! So Cool, it's perfect !
Thanks you ! Exactly what I wanted!
Very fast and efficient, thank you
_________________ Linux a un noyau, Windows a des pépins.
|
|
Back to top
|
|
 |
|
|
|
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
|