The time now is Wed 19 Jun 2013, 03:07
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. 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.
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.
Edited_time_total
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1800 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: 1800 Location: Burghaslach, Germany
|
Posted: 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
|
|
 |
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
|
|
 |
|
|
|
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
|