echo $LINE >>PuppyPin, cuts spaces (SOLVED)

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

echo $LINE >>PuppyPin, cuts spaces (SOLVED)

#1 Post by sunburnt »

I'm writing to PuppyPin line by line with: echo "$LINE" >> /tmp/PuppyPin
This cuts leading spaces in the XML formatting off of each line.
I know it'll still work this way, but I'm a bit of a stickler for details.
I'd add the spaces in, but some lines have none, some have 2, some have 4, etc.

I tried using sed to write the first part of the file, then add the new line to the file,
& then have sed write the rest of the file after that... couldn't do it (sort of).
I don't know if using sed would have solved the cut off leading spaces.

Suggestion: I've suggested this before, & there may already be something like it.

Have utilities for each of the WM menu types to automate adding & deleteing lines.
Run one command to make a JWM or IceWM menu entry, or make a ROX desktop icon.
This is another way of handling the job done by the; "unified menus project".
The unified menus should have this sort of utility anyway.
Last edited by sunburnt on Wed 20 Sep 2006, 06:25, edited 1 time in total.

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#2 Post by MU »

the menus ideally will be replaced by the XDG-system in future.

In my 3D-Control-Center I use a tool written in PuppyBasic to remove or insert lines to configfiles.
You can use it like other comandlineprograms from within a shellscript.

Wait... there it is:
http://www.murga.org/~puppy/viewtopic.php?t=8271

Mark

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#3 Post by MU »

If you only want to append a line, use this small program "appendlinetofile":

Code: Select all

#!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"

if command() != 4 then
  usage()
end if

theline = command(3)
thefile = command(4)

appendstringtofile(thefile , theline)

if ! fileexists(thefile) then
  shell("echo write error >&2")
  end
end if

sub usage()
  shell("echo usage: appendlinetofile \"line\" file >&2")
  end
end sub
Mark

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#4 Post by GuestToo »

Code: Select all

LINE='     hello     '
echo "$LINE" >> /tmp/lines.txt
echo "$LINE" >> /tmp/lines.txt

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#5 Post by MU »

why easy if it works complicated? :lol:
Thanks GuestToo :P

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

I guess I should have put the code in:

Code: Select all

cat /root/Choices/ROX-Filer/PuppyPin |
while read LINE
do
 echo "$LINE" >> /tmp/PuppyPin

 if [ "$LINE" = '<pinboard>' ];then				# write line to file

  echo '  <icon x="320" y="384" label="LogOut">/root/my-applications/bin/login-puppy_local</icon>' >> /tmp/PuppyPin
 fi
done

I'm trying to add an icon link to the ROX desktop, there's more code for "globicons".

I have a file of "Sed one liners", I got the first part of the PuppyPin file to write.
But none of the one liners would print after a given line to the end of the file.

As any app. install or removal, the Menu files need lines added or removed.
One utility for each WM's menu, one for ROX's desktop, & one for XDG menus?

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#7 Post by sunburnt »

Got it, after digging through the sed one liners I found a combination of print or delete the first 2 lines.
This code adds a ROX desktop icon by writing to 2 ROX files.

Code: Select all

							### ROX desktop link

cat /root/Choices/ROX-Filer/PuppyPin | sed 2q > /tmp/PuppyPin		# write first 2 lines
echo '  <icon x="320" y="384" label="LogOut">/root/my-applications/bin/login-puppy_local</icon>' >> /tmp/PuppyPin
cat /root/Choices/ROX-Filer/PuppyPin | sed '1,2d' >> /tmp/PuppyPin	# write rest of lines

							### ROX desktop icon

cat /root/Choices/ROX-Filer/globicons | sed 2q > /tmp/globicons		# write first 2 lines
echo '  <rule match="/root/my-applications/bin/login-puppy_local">' >> /tmp/globicons
echo '    <icon>/root/my-applications/bin/pup-paw_trans_sm.xpm</icon>' >> /tmp/globicons
echo '  </rule>' >> /tmp/globicons
cat /root/Choices/ROX-Filer/globicons | sed '1,2d' >> /tmp/globicons	# write rest of lines

Now to examine the menu files for: JWM, IceWM, & Xfce, to make utilities.

Post Reply